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
1c64c1e9
Unverified
Commit
1c64c1e9
authored
Feb 19, 2020
by
Quinn Turner
Committed by
GitHub
Feb 19, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: Improve grammar of apollo.js comments (#10601)
parent
0acea5f4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
apollo.js
examples/with-apollo/lib/apollo.js
+8
-8
No files found.
examples/with-apollo/lib/apollo.js
View file @
1c64c1e9
...
...
@@ -3,12 +3,12 @@ import App from 'next/app'
import
{
ApolloProvider
}
from
'@apollo/react-hooks'
import
createApolloClient
from
'../apolloClient'
// On the client
we store the apollo client in the following variable
//
t
his prevents the client from reinitializing between page transitions.
// On the client
, we store the Apollo Client in the following variable.
//
T
his prevents the client from reinitializing between page transitions.
let
globalApolloClient
=
null
/**
* Install
es the apollo c
lient on NextPageContext
* Install
s the Apollo C
lient on NextPageContext
* or NextAppContext. Useful if you want to use apolloClient
* inside getStaticProps, getStaticPaths or getServerProps
* @param {NextPageContext | NextAppContext} ctx
...
...
@@ -32,13 +32,13 @@ export const initOnContext = ctx => {
ctx
.
apolloClient
||
initApolloClient
(
ctx
.
apolloState
||
{},
inAppContext
?
ctx
.
ctx
:
ctx
)
//
To avoid calling initApollo() twice in the server we send the Apollo Client as a prop
//
to the component, otherwise
the component would have to call initApollo() again but this
// time without the context
, once that happens
the following code will make sure we send
// the prop as `null` to the browser
//
We send the Apollo Client as a prop to the component to avoid calling initApollo() twice in the server.
//
Otherwise,
the component would have to call initApollo() again but this
// time without the context
. Once that happens,
the following code will make sure we send
// the prop as `null` to the browser
.
apolloClient
.
toJSON
=
()
=>
null
// Add apolloClient to NextPageContext & NextAppContext
// Add apolloClient to NextPageContext & NextAppContext
.
// This allows us to consume the apolloClient inside our
// custom `getInitialProps({ apolloClient })`.
ctx
.
apolloClient
=
apolloClient
...
...
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