Commit 4570f2d0 authored by Will Meier's avatar Will Meier Committed by Tim Neutkens

Update with-apollo examples (#4067)

* Update with-apollo examples to include note about top-level withData HOC

* Update with-apollo examples to include note about top-level withData HOC
parent ebf0c47c
...@@ -49,3 +49,6 @@ export default withReduxSaga(connect(mapStateToProps, null)(Index)); ...@@ -49,3 +49,6 @@ export default withReduxSaga(connect(mapStateToProps, null)(Index));
``` ```
`connect` must go inside `withReduxSaga` otherwise `connect` will not be able to find the store. `connect` must go inside `withReduxSaga` otherwise `connect` will not be able to find the store.
### Note:
In these *with-apollo* examples, the ```withData()``` HOC must wrap a top-level component from within the ```pages``` directory. Wrapping a child component with the HOC will result in a ```Warning: Failed prop type: The prop 'serverState' is marked as required in 'WithData(Apollo(Component))', but its value is 'undefined'``` error. Down-tree child components will have access to Apollo, and can be wrapped with any other sort of ```graphql()```, ```compose()```, etc HOC's.
...@@ -48,4 +48,7 @@ const mapStateToProps = state => ({ ...@@ -48,4 +48,7 @@ const mapStateToProps = state => ({
}); });
export default withRedux(connect(mapStateToProps, null)(Index)); export default withRedux(connect(mapStateToProps, null)(Index));
``` ```
\ No newline at end of file
### Note:
In these *with-apollo* examples, the ```withData()``` HOC must wrap a top-level component from within the ```pages``` directory. Wrapping a child component with the HOC will result in a ```Warning: Failed prop type: The prop 'serverState' is marked as required in 'WithData(Apollo(Component))', but its value is 'undefined'``` error. Down-tree child components will have access to Apollo, and can be wrapped with any other sort of ```graphql()```, ```compose()```, etc HOC's.
...@@ -66,3 +66,7 @@ It is important to note the use of Apollo's `resetStore()` method after signing ...@@ -66,3 +66,7 @@ It is important to note the use of Apollo's `resetStore()` method after signing
To get this example running locally, you will need to create a graph.cool To get this example running locally, you will need to create a graph.cool
account, and provide [the `project.graphcool` schema](https://github.com/zeit/next.js/blob/master/examples/with-apollo-auth/project.graphcool). account, and provide [the `project.graphcool` schema](https://github.com/zeit/next.js/blob/master/examples/with-apollo-auth/project.graphcool).
### Note:
In these *with-apollo* examples, the ```withData()``` HOC must wrap a top-level component from within the ```pages``` directory. Wrapping a child component with the HOC will result in a ```Warning: Failed prop type: The prop 'serverState' is marked as required in 'WithData(Apollo(Component))', but its value is 'undefined'``` error. Down-tree child components will have access to Apollo, and can be wrapped with any other sort of ```graphql()```, ```compose()```, etc HOC's.
...@@ -48,3 +48,6 @@ In this simple example, we integrate Apollo seamlessly with Next by wrapping our ...@@ -48,3 +48,6 @@ In this simple example, we integrate Apollo seamlessly with Next by wrapping our
On initial page load, while on the server and inside `getInitialProps`, we invoke the Apollo method, [`getDataFromTree`](http://dev.apollodata.com/react/server-side-rendering.html#getDataFromTree). This method returns a promise; at the point in which the promise resolves, our Apollo Client store is completely initialized. On initial page load, while on the server and inside `getInitialProps`, we invoke the Apollo method, [`getDataFromTree`](http://dev.apollodata.com/react/server-side-rendering.html#getDataFromTree). This method returns a promise; at the point in which the promise resolves, our Apollo Client store is completely initialized.
This example relies on [graph.cool](https://www.graph.cool) for its GraphQL backend. This example relies on [graph.cool](https://www.graph.cool) for its GraphQL backend.
### Note:
In these *with-apollo* examples, the ```withData()``` HOC must wrap a top-level component from within the ```pages``` directory. Wrapping a child component with the HOC will result in a ```Warning: Failed prop type: The prop 'serverState' is marked as required in 'WithData(Apollo(Component))', but its value is 'undefined'``` error. Down-tree child components will have access to Apollo, and can be wrapped with any other sort of ```graphql()```, ```compose()```, etc HOC's.
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