import { ApolloClient, InMemoryCache, createHttpLink, from } from '@apollo/client'; import { onError } from '@apollo/client/link/error'; const httpLink = createHttpLink({ uri: 'http://localhost:4000/graphql', }); const errorLink = onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.forEach(({ message, locations, path }) => console.error( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}` ) ); if (networkError) console.error(`[Network error]: ${networkError}`); }); export const client = new ApolloClient({ link: from([errorLink, httpLink]), cache: new InMemoryCache({ typePolicies: { Query: { fields: { groups: { merge(_, incoming) { return incoming; }, }, tasks: { merge(_, incoming) { return incoming; }, }, }, }, }, }), });