Last active
September 8, 2022 02:37
-
-
Save joshmenden/d0e1eb3190a89568984af3f7eb312b93 to your computer and use it in GitHub Desktop.
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
| 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