1234567891011121314151617181920212223242526272829303132 |
- import withApollo from 'next-with-apollo'
- import ApolloClient from 'apollo-boost'
- import { endpoint, prodEndpoint } from '../config'
- function createClient ({ ctx, headers, initialState }) {
- return new ApolloClient({
- uri: process.env.NODE_ENV === 'development' ? endpoint : prodEndpoint,
- request: operation => {
- operation.setContext({
- fetchOptions: {
- credentials: 'include'
- },
- headers
- })
- },
- clientState: {
- resolvers: {},
- defaults: {}
- }
- })
- }
- export default withApollo(createClient)
|