Last active
September 3, 2022 01:26
-
-
Save joshmenden/7c45752f74bed8f117bfc7e45816ed68 to your computer and use it in GitHub Desktop.
This file contains 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
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