Created
November 25, 2019 21:17
-
-
Save wendelnascimento/3ab3517e35c7f7922c8747570422b9a2 to your computer and use it in GitHub Desktop.
apolloConfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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