Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
fbcc0e81
Unverified
Commit
fbcc0e81
authored
Jan 03, 2020
by
Luis Alvarez D
Committed by
GitHub
Jan 03, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
😌
(#9923)
parent
2f1b15c6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
11 deletions
+11
-11
client.js
...ples/api-routes-apollo-server-and-client/apollo/client.js
+4
-4
apollo.js
examples/with-apollo-and-redux/lib/apollo.js
+4
-4
apollo.js
examples/with-apollo/lib/apollo.js
+3
-3
No files found.
examples/api-routes-apollo-server-and-client/apollo/client.js
View file @
fbcc0e81
...
...
@@ -4,7 +4,7 @@ import { ApolloProvider } from '@apollo/react-hooks'
import
{
ApolloClient
}
from
'apollo-client'
import
{
InMemoryCache
}
from
'apollo-cache-inmemory'
let
a
polloClient
=
null
let
globalA
polloClient
=
null
/**
* Creates and provides the apolloContext
...
...
@@ -110,11 +110,11 @@ function initApolloClient(initialState) {
}
// Reuse client on the client-side
if
(
!
a
polloClient
)
{
a
polloClient
=
createApolloClient
(
initialState
)
if
(
!
globalA
polloClient
)
{
globalA
polloClient
=
createApolloClient
(
initialState
)
}
return
a
polloClient
return
globalA
polloClient
}
/**
...
...
examples/with-apollo-and-redux/lib/apollo.js
View file @
fbcc0e81
...
...
@@ -6,7 +6,7 @@ import { InMemoryCache } from 'apollo-cache-inmemory'
import
{
HttpLink
}
from
'apollo-link-http'
import
fetch
from
'isomorphic-unfetch'
let
a
polloClient
=
null
let
globalA
polloClient
=
null
/**
* Creates and provides the apolloContext
...
...
@@ -112,11 +112,11 @@ function initApolloClient(initialState) {
}
// Reuse client on the client-side
if
(
!
a
polloClient
)
{
a
polloClient
=
createApolloClient
(
initialState
)
if
(
!
globalA
polloClient
)
{
globalA
polloClient
=
createApolloClient
(
initialState
)
}
return
a
polloClient
return
globalA
polloClient
}
/**
...
...
examples/with-apollo/lib/apollo.js
View file @
fbcc0e81
...
...
@@ -44,7 +44,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
// Initialize ApolloClient, add it to the ctx object so
// we can use it in `PageComponent.getInitialProp`.
globalApolloClient
=
ctx
.
apolloClient
=
initApolloClient
(
)
const
apolloClient
=
(
ctx
.
apolloClient
=
initApolloClient
()
)
// Run wrapped getInitialProps methods
let
pageProps
=
{}
...
...
@@ -69,7 +69,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
<
AppTree
pageProps
=
{{
...
pageProps
,
globalA
polloClient
,
a
polloClient
,
}}
/
>
)
...
...
@@ -87,7 +87,7 @@ export function withApollo(PageComponent, { ssr = true } = {}) {
}
// Extract query data from the Apollo store
const
apolloState
=
globalA
polloClient
.
cache
.
extract
()
const
apolloState
=
a
polloClient
.
cache
.
extract
()
return
{
...
pageProps
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment