1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Fix ssr auth bug and dependency problems (#5543)

* fix graphql dep

* fix ssr auth bug

* fix linting issues
This commit is contained in:
Janek Rahrt 2018-10-28 21:13:28 +01:00 committed by Tim Neutkens
parent e382be655c
commit a7b6ffa914
2 changed files with 3 additions and 8 deletions

View file

@ -22,9 +22,8 @@ export default App => {
static async getInitialProps (ctx) {
const { Component, router, ctx: { req, res } } = ctx
const token = parseCookies(req).token
const apollo = initApollo({}, {
getToken: () => token
getToken: () => parseCookies(req).token
})
ctx.ctx.apolloClient = apollo
@ -70,20 +69,16 @@ export default App => {
return {
...appProps,
apolloState,
token
apolloState
}
}
constructor (props) {
super(props)
const { token } = props
// `getDataFromTree` renders the component first, the client is passed off as a property.
// After that rendering is done using Next's normal rendering pipeline
this.apolloClient = initApollo(props.apolloState, {
getToken: () => {
if (token) { return token }
return parseCookies().token
}
})

View file

@ -12,7 +12,7 @@
"apollo-boost": "^0.1.6",
"apollo-link-context": "^1.0.8",
"cookie": "^0.3.1",
"graphql": "^0.13.2",
"graphql": "14.0.2",
"isomorphic-unfetch": "^2.0.0",
"next": "latest",
"prop-types": "^15.6.1",