Based on https://github.com/vercel/next.js/pull/13607 - I created a new PR as I can't push changes to the initial PR.
Migrated the Apollo client to use SSG, also removed the link to the live demo because I don't know who the owner is or how to update the deployment.
The implementation is pretty simple and will be added to all the other Apollo examples
* Make withApollo work with _app.js components
* Support wrapping functional _App
* Add apolloClient to NextPageContext & NextPageContext
* Propertly call App.getInitialProps if used in NextAppContext
* Add Automatic Static Optimization warning
* Update deps
* Reduce API surface
* Move back to singleton client
* Improve documentation
* Remove Head.rewind()
We can get rid of .rewind by now as the latest next/head no longer uses legacy context.
* Add extra docs
* Reuse apolloState coming from previous hocs
Co-authored-by: Joe Haddad <timer150@gmail.com>
* Fix getInitialProps in with-apollo example
The code before had two design flaws:
* When we skip WithApollo.getInitialProps we must hoist PageComponent.getInitialProps if it is present.
* We should expose the apolloClient to underlying PageComponent.getInitialProps contexts.
* Add abort check
* Add some comments
* Add client only example page
https://github.com/zeit/next.js/pull/8620#issuecomment-527870886
* Remove connectToDevTools setting in favor default config
7eaf4132cd/packages/apollo-client/src/ApolloClient.ts (L170-L173)
* Remove fetch check
This is done by https://www.npmjs.com/package/isomorphic-unfetch
* Remove apollo-boost
I am removing this package, because we never actually used it.
This is because we use the named export of apollo boost wich resolves to apollo-client.
This way we removed apollo-link-state, apollo-link-error
* Remove redirect code from the client
* Simplify apollo setup
* Allow disabling of ssr in favor of automatic static optimization
- Converted Class to Function Component
- Added ssr config option
* Exclude @apollo/react-ssr from client bundle
* Remove WithApollo.getInitialProps from the client
* Remove displayName from production build
* Fix production switch
* Change export & fucntion naming
- Use named export
- Change function naming
* Warn if someone tries to use this HOC with _app.js
* Remove _app from with-apollo example
This allows automatic static optimization for pages, that don’t need apollo.
* Rename with-apollo
Name should be same as hoc
* Adjust text to reflect latest changes
more info: 4321c469466160d13bcd52afa099385e84a112a0
* Add new apollo example
* Update readme
* Update with-apollo to use _app.js
* Move withData to _app
* Make SSR work again
* Remove withData
* Use HOC to provide apolloClient
* Spread pageprops
* Add minimal apollo example
* Update apollo example README
* Update apollo example demo link in README
* Fix button styles
* Fix show more button
* Alias demo url
* Include the data field on the Apollo store when hydrating
* Revert
* Include the data field on the Apollo store when hydrating per tpreusse's suggestion.
* Add example to faq section in README
* Sort by newest; Add active state to buttons
* Make optimization suggestions
* Use process.browser; inline props