-
-
Save remy/faae63f3d8238cbb6ea2b6fc8dea0f45 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
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