c6708b2c1f
* feat: wip rewrite auth * feat: restructure folders and fix stories and tests * feat: remove auth provider and fix tests
37 lines
856 B
TypeScript
37 lines
856 B
TypeScript
import { InMemoryCache } from '@apollo/client';
|
|
|
|
import { tokenService } from '@/auth/services/TokenService';
|
|
import { CommentThreadTarget } from '~/generated/graphql';
|
|
|
|
import { ApolloFactory } from './apollo.factory';
|
|
|
|
const apollo = new ApolloFactory({
|
|
uri: `${process.env.REACT_APP_API_URL}`,
|
|
cache: new InMemoryCache({
|
|
typePolicies: {
|
|
CommentThread: {
|
|
fields: {
|
|
commentThreadTargets: {
|
|
merge(
|
|
existing: CommentThreadTarget[] = [],
|
|
incoming: CommentThreadTarget[],
|
|
) {
|
|
return [...incoming];
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}),
|
|
defaultOptions: {
|
|
query: {
|
|
fetchPolicy: 'cache-first',
|
|
},
|
|
},
|
|
onUnauthenticatedError() {
|
|
tokenService.removeTokenPair();
|
|
},
|
|
});
|
|
|
|
export const apolloClient = apollo.getClient();
|