Created
May 30, 2019 21:44
-
-
Save ghankerson/06b3b967fbd9c33b5c876534da3839e4 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
| import fetch from 'cross-fetch'; | |
| import { ApolloClient } from 'apollo-client'; | |
| import { createHttpLink } from 'apollo-link-http'; | |
| import { InMemoryCache } from 'apollo-cache-inmemory'; | |
| import FragmentMatcher from './FragmentMatcher'; | |
| const cache = new InMemoryCache({ fragmentMatcher: FragmentMatcher }).restore(window.__APOLLO_STATE__); | |
| export function client(graphqlEnv) { | |
| return new ApolloClient({ | |
| ssrForceFetchDelay: 100, | |
| cache, | |
| link: createHttpLink({ | |
| uri: `https://cmsproxy${graphqlEnv}.publicradio.org/api/v1/graphql`, | |
| fetch: fetch | |
| }), | |
| cacheRedirects: { | |
| Query: { | |
| episode: (_, { id }, { getCacheKey }) => getCacheKey({ id, __typename: 'Episode' }) | |
| } | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment