You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pessimistic Updates with infiniteQuery Not Working (selectCachedArgsForQuery Issue)
Description
I'm trying to use selectCachedArgsForQuery with an infiniteQuery in RTK Query, but I get a TypeScript error:
Argument of type '"getApplications"' is not assignable to parameter of type 'QueryKeys<{ getApplications: InfiniteQueryDefinition<...>; ... }>'.ts(2345)
I suspect that selectCachedArgsForQuery does not support infiniteQuery, and there is no equivalent function like selectCachedArgsForInfiniteQuery.
Code Example
asynconQueryStarted(productId,_api){const{ dispatch, queryFulfilled }=_api;conststate=_api.getState();try{awaitqueryFulfilled;constargs=applicationApi.util.selectCachedArgsForQuery(state,"getApplications",// Infinite query);args.forEach((arg)=>{dispatch(applicationApi.util.updateQueryData("getApplications",arg,(prevData)=>prevData,// No modification, just checking structure),);});}catch(error){console.error(error);}}
Expected Behavior
selectCachedArgsForQuery should return the correct cached arguments for an infiniteQuery.
If selectCachedArgsForQuery does not support infiniteQuery, an alternative method (e.g., selectCachedArgsForInfiniteQuery) should be provided.
Observed Behavior
TypeScript throws an error that "getApplications" is not assignable to the expected type.
There is no documented way to get cached arguments for infiniteQuery.
Possible Fixes
Add support for selecting cached arguments from infiniteQuery.
Provide a utility function like selectCachedArgsForInfiniteQuery.
Improve documentation to clarify how to manually retrieve cached arguments for infiniteQuery.
Pessimistic Updates with
infiniteQuery
Not Working (selectCachedArgsForQuery
Issue)Description
I'm trying to use
selectCachedArgsForQuery
with aninfiniteQuery
in RTK Query, but I get a TypeScript error:I suspect that
selectCachedArgsForQuery
does not supportinfiniteQuery
, and there is no equivalent function likeselectCachedArgsForInfiniteQuery
.Code Example
Expected Behavior
selectCachedArgsForQuery
should return the correct cached arguments for aninfiniteQuery
.selectCachedArgsForQuery
does not supportinfiniteQuery
, an alternative method (e.g.,selectCachedArgsForInfiniteQuery
) should be provided.Observed Behavior
"getApplications"
is not assignable to the expected type.infiniteQuery
.Possible Fixes
infiniteQuery
.selectCachedArgsForInfiniteQuery
.infiniteQuery
.Originally posted by @User6531 in #4858 (comment)
The text was updated successfully, but these errors were encountered: