Replies: 1 comment
-
|
Yes, this is totally fine — it's a recognized pattern called the "push approach" to cache seeding, and TkDodo wrote a whole post about it: Seeding the Query Cache. The TanStack docs also cover it in the Prefetching guide. The idea is exactly what you're doing: a single API call returns data for multiple queries, so you write the related data into the cache proactively instead of making extra network requests later. A few things worth knowing with your specific setup:
The The exception: if you have queryClient.setQueryDefaults(invoiceSettingsQueryKeys.detail(id), {
gcTime: 5 * 60 * 1000, // 5 minutes
});
When a component mounts with queryClient.setQueryDefaults(invoiceSettingsQueryKeys.detail(id), {
staleTime: 60 * 1000,
});One thing to check: data structure completeness This only works cleanly if the Overall, the pattern is solid. The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello I want to ask if something like that is fine todo:
i.e. the
client.setQueryData.Beta Was this translation helpful? Give feedback.
All reactions