Open JacobJaffe opened 1 year ago
Alternatively, is there a way isRefetching
could be added to the query, in addition to isLoading
and isFetching
?
Where isRefetching
is true if the query is triggered by either:
query.refetch()
forceRefetch
condition of the query definition
The changes to allow awaiting
query.refetch()
are really nice, as is the ability now to build paginated flows withmerge
/forceRefetch
/serializeQueryArgs
.Is there a way that promsie-based refetch could work with
forceRefetch
?For context, I'm using a pattern very similar to https://github.com/reduxjs/redux-toolkit/issues/2874 where pagination cursor indicates a full-refresh from the head of the list.
Here's a basic example, where an endpoint would take an item as a cursor for the next page, or no cursor for the head:
With a normal query, this is now easily achievable via something like:
But since the refresh is triggered by the param change, it feels like it's back to needing a solution like pre-promise-refetch ( like tracking
isFetching
and trying to ensure the cause of the fetching is known)...
Conceptually, what I want is trigger a refetch and await it in a single step: