From 15482d8902e123818e66f669a52916a7143e0a43 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Tue, 25 Oct 2022 13:13:54 +0200 Subject: [PATCH] fix(graphcache): case where a mutation would also be counted in the loop-protection (#2761) --- .changeset/flat-feet-look.md | 5 +++++ exchanges/graphcache/src/cacheExchange.ts | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 .changeset/flat-feet-look.md diff --git a/.changeset/flat-feet-look.md b/.changeset/flat-feet-look.md new file mode 100644 index 0000000000..5e67937e33 --- /dev/null +++ b/.changeset/flat-feet-look.md @@ -0,0 +1,5 @@ +--- +"@urql/exchange-graphcache": patch +--- + +Fix case where a mutation would also be counted in the loop-protection, this prevented partial queries from initiating refetches diff --git a/exchanges/graphcache/src/cacheExchange.ts b/exchanges/graphcache/src/cacheExchange.ts index 6b8d51d386..e25e53542b 100644 --- a/exchanges/graphcache/src/cacheExchange.ts +++ b/exchanges/graphcache/src/cacheExchange.ts @@ -103,7 +103,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).add(operation.key); + if (operation.kind === 'query') { + (reexecutingOperations = dependentOperations).add(operation.key); + } (dependentOperations = _reexecutingOperations).clear(); };