Commit 7e8acf3a authored by Brice BERNARD's avatar Brice BERNARD Committed by Tim Neutkens

[with-apollo-auth] simplify apolloState prop (#4563)

We don't need `.data` as `apollo.cache.extract()` returns at least `{}` when cache is empty
parent e318de62
...@@ -17,9 +17,7 @@ export default App => { ...@@ -17,9 +17,7 @@ export default App => {
return class WithData extends React.Component { return class WithData extends React.Component {
static displayName = `WithData(${App.displayName})` static displayName = `WithData(${App.displayName})`
static propTypes = { static propTypes = {
apolloState: PropTypes.shape({ apolloState: PropTypes.object.isRequired
data: PropTypes.object.isRequired
}).isRequired
} }
static async getInitialProps(ctx) { static async getInitialProps(ctx) {
...@@ -67,7 +65,7 @@ export default App => { ...@@ -67,7 +65,7 @@ export default App => {
} }
// Extract query data from the Apollo's store // Extract query data from the Apollo's store
const apolloState = { data: apollo.cache.extract() } const apolloState = apollo.cache.extract()
return { return {
...appProps, ...appProps,
...@@ -79,7 +77,7 @@ export default App => { ...@@ -79,7 +77,7 @@ export default App => {
super(props) super(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.data, { this.apolloClient = initApollo(props.apolloState, {
getToken: () => parseCookies().token getToken: () => parseCookies().token
}) })
} }
......
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