-
Notifications
You must be signed in to change notification settings - Fork 27k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix assignment of props in WithApollo.getInitialProps #11236
Conversation
The props are being assigned incorrectly based on the `inAppContext`, they should be wrapped in `pageProps` when `inAppContext` is true, not the other way around. This will cause a new apollo client to be created during `getDataFromTree` instead of using the one that has already been created on the server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bgoerdt Thank you!
Hey, this is unrelated to this PR. However I couldn't find a better place to ask. In the following snippet... // We consider installing `withApollo({ ssr: true })` on global App level
// as antipattern since it disables project wide Automatic Static Optimization.
if (process.env.NODE_ENV === 'development') {
if (inAppContext) {
console.warn(
'Warning: You have opted-out of Automatic Static Optimization due to `withApollo` in `pages/_app`.\n' +
'Read more: https://err.sh/next.js/opt-out-auto-static-optimization\n'
)
}
} ...the comment says that it is an antipattern to use If not, shouldn't this warning be ignored if SSR is false? |
@antoniojps It should be ignored, yes. If that's not the case you're welcome to open a PR to fix it. |
hi @bgoerdt 👋 is it possible that you re-check it and maybe undo your changes? for me it's not an issue since i have a custom solution anyway but maybe for others it could be misleading. thanks for your contribution 👍 |
@zanettin yep I'll revert it. I'm not sure why it's working the opposite way in my project, but the example project is broken with my change. Sorry about that. |
@bgoerdt top. thx a lot 👍 nave a nice weekend |
The props are being assigned incorrectly based on the
inAppContext
, they should be wrapped inpageProps
wheninAppContext
is true, not the other way around. This bug will cause a new apollo client to be created duringgetDataFromTree
instead of using the one that has already been created on the server.