Skip to content

Commit 1a49882

Browse files
committed
Refactor getCacheKey function to support fixedCacheKey in mutationThunk
1 parent ea1017f commit 1a49882

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/toolkit/src/query/core/buildMiddleware/cacheLifecycle.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,11 @@ export const buildCacheLifecycleHandler: InternalHandlerBuilder = ({
251251
}
252252
}
253253

254-
function getCacheKey(action: any) {
254+
function getCacheKey(action: any) {
255255
if (isQueryThunk(action)) return action.meta.arg.queryCacheKey
256-
if (isMutationThunk(action)) return action.meta.requestId
256+
if (isMutationThunk(action)) {
257+
return action.meta.arg.fixedCacheKey ?? action.meta.requestId;
258+
}
257259
if (api.internalActions.removeQueryResult.match(action))
258260
return action.payload.queryCacheKey
259261
if (api.internalActions.removeMutationResult.match(action))

0 commit comments

Comments
 (0)