Second query in dependent query outputs `status - "success"` before fetching
See original GitHub issueSubject of the issue
Issue in dependent query fetching,
Even before the second query starts fetching, the status - success
is returned
My environment
- version of react-query - 1.5.3
- version of next-js - 9.4.2
Steps to reproduce
Issue reproduced in codesandbox - https://codesandbox.io/s/react-query-doubts-j3fhh
Expected behaviour
Second Query should be returning status - loading
till the isFetching
is done.
Actual behaviour
Note:
I can directly await
for the both the query in the same useQuery, but in my use-case, I have to useQuery to fetch primary data and with the above fetched data as dependency for useInfiniteQuery to get the final data. In the end, I need both primary data and the final data.
Also I cannot await
for both the query inside useInfiniteQuery, because I need the data from both the query to be availabe in the resulted data.
But useInfiniteQuery returns an array which becomes hard to get the data from first query.
Also I see that useInfiniteQuery calls the fetchFunction twice during the initial page load during my experiment.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
@tannerlinsley I feel like this is still a bug that doesn’t behave as documented, rather than a general idea that should be addressed at some point in the future…
Surely the expected behaviour here is that the dependent query’s status should be
loading
until the first query returns truthy?I have a query that’s never been fetched, and is waiting for some other query to complete, yet the status is
success
. This doesn’t make sense. It means everywhere I have interdependent queries (which for me is in a lot of places) I have to add multiple other checks and safeguards.Indeed. even with this new issue, my response remains the same. This is something we will have to address in future major (breaking) versions of the library.