Skip to content

Instantly share code, notes, and snippets.

@wendelnascimento
Created November 25, 2019 21:17
Show Gist options
  • Save wendelnascimento/3ab3517e35c7f7922c8747570422b9a2 to your computer and use it in GitHub Desktop.
Save wendelnascimento/3ab3517e35c7f7922c8747570422b9a2 to your computer and use it in GitHub Desktop.
apolloConfig
import { ApolloClient } from 'apollo-client';
import { InMemoryCache } from 'apollo-cache-inmemory';
import { createUploadLink } from 'apollo-upload-client';
import { onError } from 'apollo-link-error';
import { ApolloLink } from 'apollo-link';
const client = new ApolloClient({
link: ApolloLink.from([
onError(({ graphQLErrors, networkError }) => {
if (graphQLErrors)
graphQLErrors.forEach(({ message, locations, path }) =>
console.log(
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`,
),
);
if (networkError) console.log(`[Network error]: ${networkError}`);
}),
createUploadLink({
uri: 'http://localhost:4001'
}),
]),
cache: new InMemoryCache()
});
export default client;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment