-
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 getInitialProps issue in with-apollo example #8620
Conversation
366183b
to
6c2f5c4
Compare
Hey @HaNdTriX, thanks for another nice catch and addition :) I was thinking more about this example and I came to conclusion we could display more pages, with different settings so this example shows all possibilities. What do you think? |
b989366
to
fbfd6de
Compare
@huv1k I like the idea. I've added the following: 1. IndexPageCode...
export default withApollo(IndexPage) PageScreenshot2. ClientPageCode...
export default withApollo(ClientOnlyPage, {
// Disable apollo ssr fetching in favour of automatic static optimization
ssr: false
}) PageScreenshot(Please note that this screenshot will change after apollo fetched on the client.) Result
I am not sure if I want to add an |
fbfd6de
to
6b7b31e
Compare
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.
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
6b7b31e
to
549a03e
Compare
@HaNdTriX great job as always 🚀 |
2205427
to
8645aed
Compare
8645aed
to
73f6e04
Compare
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.
Looks great. thank you!
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.
Looks good 👍
For more information check vercel/next.js#8620
For more information check vercel/next.js#8620
Motivation
The code before had three design flaws:
WithApollo.getInitialProps
we must hoistPageComponent.getInitialProps
if it is present. (Special thanks to @justinnipper for pointing me into the right direction 🙏.)apolloClient
to the underlyingPageComponent.getInitialProps
contexts. This way users are able to use apollo insidePageComponent.getInitialProps
to perform prerender redirects or similar. (e.g.await ctx.apolloClient.query(...)
)Changelog
pageContext
Status: ready
Related: #8508, #8504