Commit a7b6ffa9 authored by Janek Rahrt's avatar Janek Rahrt Committed by Tim Neutkens

Fix ssr auth bug and dependency problems (#5543)

* fix graphql dep

* fix ssr auth bug

* fix linting issues
parent e382be65
...@@ -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
} }
}) })
......
...@@ -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",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment