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
a7b6ffa9
Commit
a7b6ffa9
authored
Oct 28, 2018
by
Janek Rahrt
Committed by
Tim Neutkens
Oct 28, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ssr auth bug and dependency problems (#5543)
* fix graphql dep * fix ssr auth bug * fix linting issues
parent
e382be65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
8 deletions
+3
-8
withApollo.js
examples/with-apollo-auth/lib/withApollo.js
+2
-7
package.json
examples/with-apollo-auth/package.json
+1
-1
No files found.
examples/with-apollo-auth/lib/withApollo.js
View file @
a7b6ffa9
...
@@ -22,9 +22,8 @@ export default App => {
...
@@ -22,9 +22,8 @@ export default App => {
static
async
getInitialProps
(
ctx
)
{
static
async
getInitialProps
(
ctx
)
{
const
{
Component
,
router
,
ctx
:
{
req
,
res
}
}
=
ctx
const
{
Component
,
router
,
ctx
:
{
req
,
res
}
}
=
ctx
const
token
=
parseCookies
(
req
).
token
const
apollo
=
initApollo
({},
{
const
apollo
=
initApollo
({},
{
getToken
:
()
=>
token
getToken
:
()
=>
parseCookies
(
req
).
token
})
})
ctx
.
ctx
.
apolloClient
=
apollo
ctx
.
ctx
.
apolloClient
=
apollo
...
@@ -70,20 +69,16 @@ export default App => {
...
@@ -70,20 +69,16 @@ export default App => {
return
{
return
{
...
appProps
,
...
appProps
,
apolloState
,
apolloState
token
}
}
}
}
constructor
(
props
)
{
constructor
(
props
)
{
super
(
props
)
super
(
props
)
const
{
token
}
=
props
// `getDataFromTree` renders the component first, the client is passed off as a property.
// `getDataFromTree` renders the component first, the client is passed off as a property.
// After that rendering is done using Next's normal rendering pipeline
// After that rendering is done using Next's normal rendering pipeline
this
.
apolloClient
=
initApollo
(
props
.
apolloState
,
{
this
.
apolloClient
=
initApollo
(
props
.
apolloState
,
{
getToken
:
()
=>
{
getToken
:
()
=>
{
if
(
token
)
{
return
token
}
return
parseCookies
().
token
return
parseCookies
().
token
}
}
})
})
...
...
examples/with-apollo-auth/package.json
View file @
a7b6ffa9
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
"apollo-boost"
:
"^0.1.6"
,
"apollo-boost"
:
"^0.1.6"
,
"apollo-link-context"
:
"^1.0.8"
,
"apollo-link-context"
:
"^1.0.8"
,
"cookie"
:
"^0.3.1"
,
"cookie"
:
"^0.3.1"
,
"graphql"
:
"
^0.13
.2"
,
"graphql"
:
"
14.0
.2"
,
"isomorphic-unfetch"
:
"^2.0.0"
,
"isomorphic-unfetch"
:
"^2.0.0"
,
"next"
:
"latest"
,
"next"
:
"latest"
,
"prop-types"
:
"^15.6.1"
,
"prop-types"
:
"^15.6.1"
,
...
...
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