-
Notifications
You must be signed in to change notification settings - Fork 36
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
Purpose of PreloadQuery
#330
Comments
Next.js renders in two different ways:
What you are seeing when you describe "when using just useSuspenseQuery, the query happens on the server, there's no query on the client side" is a SSR thing - your client components execute on the server, and the network request doesn't happen in the browser, because we go to great lenghts to transport that data over. If you want those in-page route navigations to receive data from your RSC server instead of your GraphQL server (to prevent request waterfalls and maybe because the connection between those two servers is faster), you need
This seems curious - does your query maybe fail from your RSC server, but not from your SSR server? |
Would it be correct to also word this as "If you want those in-page route navigations to initiate a fetch from your (nextjs) server instead of the user's client"? Just trying to re-word it to see if I actually understand it. I think I finally see the difference! I made this to test out 2 approaches ( When I start on the Home page, then click "useSuspenseQuery", you're right I definitely see the query happen in my browser. If I go back to the home page, reload my browser, then go to "PreloadQuery", no request happens in the browser.
TBH I didn't look too much into it. I wanted to focus on a smaller test (the codesandbox linked above). It's not happening there, so I'm chalking that error up to inexperience for now. |
Yup. That wording works :)
If you ever encounter it, please open an issue on it :) I think all questions here have been answered, so I'll close this issue for now. Have a great day! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
Apologies, this isn't really an issue and is more of a discussion but it looks like there's no Discussions turned on for this repo.
Earlier at work we were investigating an issue, which brought me back to this repo and I see there's a new
PreloadQuery
component. It's description reads:So I tried it out, comparing it to a page that used
useSuspenseQuery
and ... I couldn't really see any difference? Other than withPreloadQuery
I got an error in nextjs' error overlay (something about "Query failed upstream", even though the query actually worked), and the query happened on the client side (and maybe the server, I'm not sure).But it's the claim that it can "populate the cache of your Client Components" that I'm curious about. Because when using just
useSuspenseQuery
, the query happens on the server, there's no query on the client side, and yet using the Apollo Devtools extension, I can see the query in the cache and active queries tab.So I'm just not clear on what the use case is for that component.
The text was updated successfully, but these errors were encountered: