from([ onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.map(({ message, locations, path }) => console.warn( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`, ), ); if (networkError) { window.AppContext.store.dispatch(setError(networkError)); console.warn(`[Network error]: ${networkError}`); } }), ...(__DEV__ ? [apolloLogger] : []), new HttpLink({ uri: `${process.env.APP_BASE_URL}/graphql`, credentials: 'include', }), ])
export default function createApolloClient(schema) { const link = from([ onError(({ graphQLErrors, networkError }) => { if (graphQLErrors) graphQLErrors.map(({ message, locations, path }) => console.warn( `[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`, ), ); if (networkError) console.warn(`[Network error]: ${networkError}`); }), new SchemaLink({ ...schema }), ]); return new ApolloClient({ link, cache: createCache(), ssrMode: true, queryDeduplication: true, }); }