Open sgup opened 2 weeks ago
This looks to me like you're forwarding the option the Next.js fetch cache correctly. Unfortunately, beyond that it's more of a Next.js question and I don't really know how you could best debug this, I'm sorry.
Would there be a way to do the initial fetch using RSC (which seems to respect nextjs caching), passing the data to the client component, and then "patching-in" that cache into the client-side apollo client?
Essentially a way to auto-load the rsc-client cache into the browser apollo client cache would be amazing.
I seem to have answered my own question. Using this approach Apollo Docs: Rehydrating the client-side cache, and passing in the RSC Client's cache into the <ApolloWrapper>
from the SSR Client (can maybe change it to a regular client?) in app/layout.tsx.
Usage:
useQuery
in the client components.Please don't do that, that cannot work correctly in all situations and is not supported! The App router runs in streaming SSR, worst case RSC, SSR and the browser run simulateneously, it's even possible that you'd end up starting the same request mutliple times or overriding data in the browser. We will soon ship support for that in this package, please don't try this before the next version (see #258).
The documentation you linked to is only valid for non-streaming renderToString SSR.
I see, ok! looking forward to the new support, thank you!
Actually i think what im doing right now isn't causing multiple concurrent queries, since I'm forcing static on the pages.
// page.tsc
// fetching data here with rscClient to cache for 24 hours, renders the page initially instantly without any visible loading state.
export const dynamic = 'force-static';
export const revalidate = 86400; // 24 hours
and then bootstrapping this client's cache into the browser cache, but doing a fresh query on the clientside to update the data.
Hi, first of all thanks for this amazing library.
I'm trying to figure out the proper use for rendering & caching with SSR/Next. I'm using
fetchOptions: { cache: 'force-cache' }
in the SSR Apollo Wrapper. However I'm still seeing my graphql server being hit for every request, and it always shows the loading page for a second or if i disable JS (testing on the deploy).Folder structure:
Full SSR:
Full RSC
Thanks, any help much appreciated.