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
A similar issue with "invalidate tags" was fixed in #3116
If request Q has started
Mutation M started and finished, there should be an pessimistic update of the cached data.
Once request Q finishes, it should have an pessimistic update.
If you perform updateQueryData on request Q which is in a pending status, then no changes will be made.
If you perform updateQueryData on request Q which is in a pending status, then after the completion of request Q, no changes will be made.
In my opinion, this is not correct, as it limits pessimistic updates which encourages the use of invalidatesTags, an additional request I do not want to make, because I already have the necessary data in the response from the mutation.
an example of how I try to perform an pessimistic update
const ridesApi = createApi({
baseQuery,
endpoints: builder => ({
getRides: builder.query({
query: () => 'rides'
}),
postRidePrice: builder.mutation({
query: id => ({
url: `ride/${id}`,
method: 'POST'
}),
async onQueryStarted(arg, { dispatch, queryFulfilled }) {
try {
const { data } = await queryFulfilled;
/*
this is a part of the code that helps to fix the problems described above, but it has a flaw in the expectation
const res = dispatch(ridesApi.util.getRunningQueryThunk('getRides', undefined));
if (res) {
await res;
}
*/
dispatch(
ridesApi.util.updateQueryData('getRides', undefined, rides => {
const ride = rides.find(ride => ride.id === data.id);
if (ride) {
Object.assign(ride, data);
}
})
);
} catch (e) {
console.error(e);
}
}
})
})
});
The text was updated successfully, but these errors were encountered:
A similar issue with "invalidate tags" was fixed in #3116
If you perform updateQueryData on request Q which is in a pending status, then no changes will be made.
If you perform updateQueryData on request Q which is in a pending status, then after the completion of request Q, no changes will be made.
In my opinion, this is not correct, as it limits pessimistic updates which encourages the use of invalidatesTags, an additional request I do not want to make, because I already have the necessary data in the response from the mutation.
an example of how I try to perform an pessimistic update
The text was updated successfully, but these errors were encountered: