Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save joshmenden/d0e1eb3190a89568984af3f7eb312b93 to your computer and use it in GitHub Desktop.

Select an option

Save joshmenden/d0e1eb3190a89568984af3f7eb312b93 to your computer and use it in GitHub Desktop.
const defaultOptions = {
query: {
errorPolicy: 'all',
},
mutate: {
errorPolicy: 'all',
},
}
function createClient(url) {
const uri = url
const httpLink = new HttpLink({
uri,
fetch: async (uri, options) => {
// where we inject the headers
options.headers = await getHeaders()
return fetch(uri, options)
},
})
return new ApolloClient({
// where we set an InMemoryCache
cache: new InMemoryCache(),
link: httpLink,
defaultOptions
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment