Tanstacks react-query allows to use a cache with the initalData
option. But it will still query the data initially. In a scenario where you want to save queries to the server, by loading all your data at once and then refetch part of the document upon query invalidation - is there any option to tell react-query to only fetch on query invalidation?
As an example here is the following document:
{
todos: [
{ id: "0", label: "ask SO"}
{ id: "1", label: "rate answer"}
{ id: "3", label: "give bounty"}
]
}
the query with the query key ['load', 'todos']
loads all todos. In several sub-components queries with the query key ['load', 'todo', '0']
,... should only query if its query key gets invalidated.
The example is of course simplified, but I have a scenario where the amount of sub queries can be quite huge and it is much "cheaper" and more performant to load all the date at once and then only refetch partially upon query invalidation.
I could try to implement around react-query but I might have overlooked something in the docs.