Skip to content

Instantly share code, notes, and snippets.

@joshmenden
Last active September 3, 2022 01:26
Show Gist options
  • Save joshmenden/7c45752f74bed8f117bfc7e45816ed68 to your computer and use it in GitHub Desktop.
Save joshmenden/7c45752f74bed8f117bfc7e45816ed68 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