checking my understanding: i cannot chain queries without writing them twice for hook and async fn ?
I'd like to be able to define the chain of queries once, and then useFooQuery and fetchFoo both work as intended.
Instead, if I have something rather complicated, I have to do:
and THEN also, in order to simply fetch this stuff in an async function
if I made a query that simply had
fetchD
as query fn, this would not work because it would not update if A
got invalidated. I suppose I could make its query keys a composite of all the dependent queries' keys?
is there a better way, or am I correctly understanding this?3 Replies
metropolitan-bronzeOP•2y ago
I suppose I could make its query keys a composite of all the dependent queries' keys?though sometimes the intermediate query keys are dependent on intermediate results! (in fact this is like always true for me)
rival-black•2y ago
If you use
fetchD
you are not using the cache. So on subsequent requests this is slower than having four useQuerymetropolitan-bronzeOP•2y ago
they both use cache (though i left out the specification of querykeys)
fetchD (and implicitly, fetchA, fetchB, fetchC) uses
queryClient.fetchQuery