import { ApolloClient } from 'apollo-client' import { InMemoryCache } from 'apollo-cache-inmemory' import withApollo from 'next-with-apollo' import { createHttpLink } from 'apollo-link-http' import fetch from 'isomorphic-unfetch' const GRAPHQL_URL = process.env.BACKEND_URL || 'http://localhost:1337/graphql' const link = new createHttpLink({ fetch, uri: GRAPHQL_URL }) export default withApollo( ({initialState}) => new ApolloClient({ link, cache: new InMemoryCache() .restore(initialState || {}) }) )