Commit dca2ca6f authored by Kenneth Luján Rosas's avatar Kenneth Luján Rosas Committed by Tim Neutkens

[with-apollo] simplify apolloState prop (#4755)

As seen on `with-apollo-auth` there are some things that need to be addressed here too.

* #4554 remove useless `apolloState` from App props on `getDataFromTree`
* #4563 simplify `apolloState` prop

Let me know if further changes/fixes are needed. 
Thank you 🎉 
parent 1a3f9507
...@@ -13,8 +13,6 @@ export default (App) => { ...@@ -13,8 +13,6 @@ export default (App) => {
appProps = await App.getInitialProps(ctx) appProps = await App.getInitialProps(ctx)
} }
const apolloState = {}
// Run all GraphQL queries in the component tree // Run all GraphQL queries in the component tree
// and extract the resulting data // and extract the resulting data
const apollo = initApollo() const apollo = initApollo()
...@@ -26,7 +24,6 @@ export default (App) => { ...@@ -26,7 +24,6 @@ export default (App) => {
{...appProps} {...appProps}
Component={Component} Component={Component}
router={router} router={router}
apolloState={apolloState}
apolloClient={apollo} apolloClient={apollo}
/> />
) )
...@@ -40,12 +37,10 @@ export default (App) => { ...@@ -40,12 +37,10 @@ export default (App) => {
// getDataFromTree does not call componentWillUnmount // getDataFromTree does not call componentWillUnmount
// head side effect therefore need to be cleared manually // head side effect therefore need to be cleared manually
Head.rewind() Head.rewind()
}
// Extract query data from the Apollo store // Extract query data from the Apollo store
apolloState.data = apollo.cache.extract() const apolloState = apollo.cache.extract()
} else {
apolloState.data = {}
}
return { return {
...appProps, ...appProps,
...@@ -55,7 +50,7 @@ export default (App) => { ...@@ -55,7 +50,7 @@ export default (App) => {
constructor (props) { constructor (props) {
super(props) super(props)
this.apolloClient = initApollo(props.apolloState.data) this.apolloClient = initApollo(props.apolloState)
} }
render () { render () {
......
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