mirror of
https://github.com/sergeyyarkov/next-apollo-graphql-setup.git
synced 2026-10-11 18:29:36 +03:00
restore
This commit is contained in:
parent
c4add51ac1
commit
96fe118a88
@ -1,18 +0,0 @@
|
|||||||
import { ApolloClient } from 'apollo-client'
|
|
||||||
import { InMemoryCache } from 'apollo-cache-inmemory'
|
|
||||||
import { HttpLink } from 'apollo-link-http'
|
|
||||||
import fetch from 'isomorphic-unfetch'
|
|
||||||
|
|
||||||
export default function createApolloClient (initialState, ctx) {
|
|
||||||
// The `ctx` (NextPageContext) will only be present on the server.
|
|
||||||
// use it to extract auth headers (ctx.req) or similar.
|
|
||||||
return new ApolloClient({
|
|
||||||
ssrMode: Boolean(ctx),
|
|
||||||
link: new HttpLink({
|
|
||||||
uri: 'https://next-blog-example.herokuapp.com/graphql', // Server URL (must be absolute)
|
|
||||||
credentials: 'same-origin', // Additional fetch() options like `credentials` or `headers`
|
|
||||||
fetch
|
|
||||||
}),
|
|
||||||
cache: new InMemoryCache().restore(initialState)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user