Skip to content

Commit

Permalink
fix(graphcache): mutation would cause dependent operations and reexec…
Browse files Browse the repository at this point in the history
…uting operations become the same set

The PR urql-graphql#2761 moved `reexecutingOperations = dependentOperations` assignment
into `if (operation.kind === 'query')` guard. Thus after a completion of
mutation, `dependentOperations = _reexecutingOperations` make reexecuting and
dependent operations the same set object.
  • Loading branch information
xuanduc987 committed Sep 9, 2024
1 parent 76ef485 commit 85aff83
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exchanges/graphcache/src/cacheExchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,9 @@ export const cacheExchange =
// Upon completion, all dependent operations become reexecuting operations, preventing
// them from reexecuting prior operations again, causing infinite loops
const _reexecutingOperations = reexecutingOperations;
reexecutingOperations = dependentOperations;
if (operation.kind === 'query') {
(reexecutingOperations = dependentOperations).add(operation.key);
reexecutingOperations.add(operation.key);
}
(dependentOperations = _reexecutingOperations).clear();
}
Expand Down

0 comments on commit 85aff83

Please sign in to comment.