@ -1,4 +1,4 @@
|
||||
import { useEffect, useMemo, useRef } from 'react';
|
||||
import { useMemo, useRef } from 'react';
|
||||
import {
|
||||
ApolloLink,
|
||||
InMemoryCache,
|
||||
@ -67,16 +67,11 @@ export function useApolloFactory() {
|
||||
},
|
||||
extraLinks: isMockMode ? [mockLink] : [],
|
||||
isDebugMode,
|
||||
tokenPair,
|
||||
});
|
||||
|
||||
return apolloRef.current.getClient();
|
||||
}, [isMockMode, setTokenPair, isDebugMode]);
|
||||
|
||||
useEffect(() => {
|
||||
if (apolloRef.current) {
|
||||
apolloRef.current.updateTokenPair(tokenPair);
|
||||
}
|
||||
}, [tokenPair]);
|
||||
}, [isMockMode, setTokenPair, isDebugMode, tokenPair]);
|
||||
|
||||
return apolloClient;
|
||||
}
|
||||
|
||||
@ -30,6 +30,7 @@ export interface Options<TCacheShape> extends ApolloClientOptions<TCacheShape> {
|
||||
onUnauthenticatedError?: () => void;
|
||||
extraLinks?: ApolloLink[];
|
||||
isDebugMode?: boolean;
|
||||
tokenPair: AuthTokenPair | null;
|
||||
}
|
||||
|
||||
export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
|
||||
@ -45,9 +46,12 @@ export class ApolloFactory<TCacheShape> implements ApolloManager<TCacheShape> {
|
||||
onUnauthenticatedError,
|
||||
extraLinks,
|
||||
isDebugMode,
|
||||
tokenPair,
|
||||
...options
|
||||
} = opts;
|
||||
|
||||
this.tokenPair = tokenPair;
|
||||
|
||||
const buildApolloLink = (): ApolloLink => {
|
||||
const httpLink = createHttpLink({
|
||||
uri,
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
import { useGetClientConfigQuery } from '~/generated/graphql';
|
||||
|
||||
export function useFetchClientConfig() {
|
||||
const { data } = useGetClientConfigQuery();
|
||||
|
||||
return data?.clientConfig;
|
||||
}
|
||||
Reference in New Issue
Block a user