Skip to content
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

Am I correct in understanding that PreloadQuery is fetching in RSC and passing the cache to the client? #397

Closed
YukiOnishi1129 opened this issue Dec 5, 2024 · 3 comments

Comments

@YukiOnishi1129
Copy link

Hello!

I have a question about the behavior of PreloadQuery.

I read here that PreloadQuery uses RSC to fetch data to the API server and passes the cache to the client component.

https://github.com/apollographql/apollo-client-nextjs?tab=readme-ov-file#preloading-data-in-rsc-for-usage-in-client-components

I am aware that the useSuspenseQuery performed by the client component only goes to take a cache and does not work with the server, is that correct?

@phryneas
Copy link
Member

phryneas commented Dec 6, 2024

Yes, PreloadQuery will make a network request on the server and then replay that in your client components, as if that request would have happened in your SSR pass or in the browser.

I am aware that the useSuspenseQuery performed by the client component only goes to take a cache and does not work with the server, is that correct?

useSuspenseQuery can only be used in the client components and as such only have a single SSR pass on first page load, unlike RSC, which will run on the server on each navigation.

@YukiOnishi1129
Copy link
Author

Thanks!

I am relieved to hear that!

Copy link
Contributor

github-actions bot commented Dec 7, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants