Skip to content

Commit 7e8acf3

Browse files
brikoutimneutkens
authored andcommitted
[with-apollo-auth] simplify apolloState prop (#4563)
We don't need `.data` as `apollo.cache.extract()` returns at least `{}` when cache is empty
1 parent e318de6 commit 7e8acf3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

examples/with-apollo-auth/lib/withApollo.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ export default App => {
1717
return class WithData extends React.Component {
1818
static displayName = `WithData(${App.displayName})`
1919
static propTypes = {
20-
apolloState: PropTypes.shape({
21-
data: PropTypes.object.isRequired
22-
}).isRequired
20+
apolloState: PropTypes.object.isRequired
2321
}
2422

2523
static async getInitialProps(ctx) {
@@ -67,7 +65,7 @@ export default App => {
6765
}
6866

6967
// Extract query data from the Apollo's store
70-
const apolloState = { data: apollo.cache.extract() }
68+
const apolloState = apollo.cache.extract()
7169

7270
return {
7371
...appProps,
@@ -79,7 +77,7 @@ export default App => {
7977
super(props)
8078
// `getDataFromTree` renders the component first, the client is passed off as a property.
8179
// After that rendering is done using Next's normal rendering pipeline
82-
this.apolloClient = initApollo(props.apolloState.data, {
80+
this.apolloClient = initApollo(props.apolloState, {
8381
getToken: () => parseCookies().token
8482
})
8583
}

0 commit comments

Comments
 (0)