Closed
Description
It is currently not clear when a previously ongoing fetch will be cancelled. Imperative methods that trigger refetches behave differently per default, like:
refetch returned from useQuery defaults cancelRefetch to false
invalidateQueries, refetchQueries and resetQueries default cancelRefetch to false
fetchNextPage and fetchPreviousPage returned from useInfiniteQuery default cancelRefetch to true
As discussed on Twitter, not cancelling a refetch when you explicitly call one of the above methods might lead to wrong data being displayed / getting out-of-sync with the backend. The safer approach would be to always cancel when the user explicitly requests a refetch with one of the above mentioned options.
Proposed solution
- Set the
cancelRefetch
flag totrue
per default on all imperative actions that support it - Users can opt-out by setting it to false