mirror of
https://github.com/sergeyyarkov/blog-example.git
synced 2026-10-11 10:19:04 +03:00
22 lines
575 B
JavaScript
22 lines
575 B
JavaScript
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 || {})
|
|
})
|
|
) |