Skip to content

Commit

Permalink
⏪️ (docs): add back comments lost in merge
Browse files Browse the repository at this point in the history
  • Loading branch information
nickadamson committed Dec 14, 2023
1 parent 1c51ace commit beac171
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/context/GRPCProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,19 @@ const getInterceptors = (logger: ReturnType<typeof useLogger>) => {
return [loggerInterceptor];
};

// Create gRPC-web transport with the given configuration.
const getWebTransport = (endpoint: string) =>
createGrpcWebTransport({
baseUrl: endpoint,
credentials: 'include', // necessary for authentication to be set
credentials: 'include', // Necessary for authentication to be set.
});

/**
* Props for the GRPCProvider component.
*/
export interface GRPCProviderProps extends PropsWithChildren {
endpoint?: string;
useDefaultReactQueryProvider?: boolean;
endpoint?: string; // Optional - overrides endpoint to use for the gRPC-web transport.
useDefaultReactQueryProvider?: boolean; // Whether to use the default React Query Provider.
}

/**
Expand All @@ -49,12 +50,13 @@ export interface GRPCProviderProps extends PropsWithChildren {
* @returns The component wrapped with the TransportProvider and optionally the QueryClientProvider.
*/
export function GRPCProvider({
endpoint = GRPC_ENDPOINT,
useDefaultReactQueryProvider = true,
endpoint = GRPC_ENDPOINT, // Default to the Production Trade-API endpoint.
useDefaultReactQueryProvider = true, // Default to true to use the QueryClientProvider.
children,
}: GRPCProviderProps) {
const logger = useLogger(); // Use the logger context.
const transport: Transport = useMemo(() => {
// Memoize the transport to avoid unnecessary re-renders.
return {
...getWebTransport(endpoint),
interceptors: getInterceptors(logger),
Expand Down

0 comments on commit beac171

Please sign in to comment.