From 4e52cf07b4f7234f947977fdd5646614a4f5e2fd Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Mon, 24 Jun 2024 14:50:55 +0200 Subject: [PATCH] fix(graphcache): Disregard write-only operation during schema awareness (#3621) --- .changeset/lazy-kangaroos-think.md | 5 +++++ exchanges/graphcache/src/operations/shared.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/lazy-kangaroos-think.md diff --git a/.changeset/lazy-kangaroos-think.md b/.changeset/lazy-kangaroos-think.md new file mode 100644 index 0000000000..6efbe2ad88 --- /dev/null +++ b/.changeset/lazy-kangaroos-think.md @@ -0,0 +1,5 @@ +--- +"@urql/exchange-graphcache": patch +--- + +Disregard write-only operation when fragment-matching with schema awareness diff --git a/exchanges/graphcache/src/operations/shared.ts b/exchanges/graphcache/src/operations/shared.ts index 4dad5e0900..bb1893a3fe 100644 --- a/exchanges/graphcache/src/operations/shared.ts +++ b/exchanges/graphcache/src/operations/shared.ts @@ -236,7 +236,10 @@ export function makeSelectionIterator( ctx.store.logger )); - if (isMatching || currentOperation === 'write') { + if ( + isMatching || + (currentOperation === 'write' && !ctx.store.schema) + ) { if (process.env.NODE_ENV !== 'production') pushDebugNode(typename, fragment); const isFragmentOptional = isOptional(select);