Skip to content

Instantly share code, notes, and snippets.

@remy

remy/withData.js Secret

Last active February 7, 2019 14:22
Show Gist options
  • Save remy/faae63f3d8238cbb6ea2b6fc8dea0f45 to your computer and use it in GitHub Desktop.
Save remy/faae63f3d8238cbb6ea2b6fc8dea0f45 to your computer and use it in GitHub Desktop.
import withApollo from 'next-with-apollo';
import ApolloClient, { InMemoryCache } from 'apollo-boost';
function createClient({ headers, initialState }) {
return new ApolloClient({
uri: process.env.API,
request: operation => {
operation.setContext({
fetchOptions: {
credentials: 'include',
},
headers,
});
},
cache: new InMemoryCache().restore(initialState || {}),
});
}
export default withApollo(createClient);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment