with-apollo & with-apollo-auth
See original GitHub issuewith-apollo & with-apollo-auth example - request
Hey!
So we’re using Next.js with Apollo & are updating our app with the new example in with-apollo[-auth] & want to be able to use it in a default on + opt-out
way rather than default off + opt-in
way.
Is your feature request related to a problem? Please describe.
Currently, the examples are all in an opt-in mode - meaning if you need apollo, you will need to wrap your page component with withApollo
explicitly. Similarly for the with-apollo-auth
example, the pages add their getInitialProps
for each page that needs to do something with user context.
Describe the solution you’d like
In our case, a lot more of the pages will need apollo + auth rather than not - eg maybe just 2 pages will not need auth and all other pages will; and almost ALL pages will need apollo. So we’re looking for a way to go back to the _app
wrapping example but we’re unable to use the current withApollo
implementation with _app
.
Describe alternatives you’ve considered
In order to use the same example with _app
, we tried changing the return pageProps
in all places to { pageProps }
, but we’re getting a bunch of errors regarding circular structure in JSON. Looks like App
does get passed the same AppTree
component we’re using but could not find any documentation regarding this AppTree
and slightly stuck here.
Any help would be appreciated. Thanks 😃
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Hey @rheaditi, you can check old examples in the GitHub history. We changed this example to reflect our prioritization of automatic prerendering.
People were blindly copying this example without knowing of its downsides. This reflected that all pages were not automatically exported and
getInitialProps
was executed even that page was static. This resulted in bad use practice, which is not our intention.Hey @rheaditi, yes for questions we have spectrum, so please ask your questions there next time. I will close this issue because it’s not how we want to examples looks like. Regarding your questions:
HoC
component forauth
, this component could have yourLayout
for these pages.getInitialProps
in your page/app your pages lose static option until we introduce prerendering during build time.