From ca4aa7bc3518531c5f5f3dbe535420d977f4a457 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Thu, 14 Dec 2023 15:18:09 +0100 Subject: [PATCH 1/2] attempt at preventing feuds in combination with a `read` function --- src/core/QueryInfo.ts | 11 +++++++++++ src/core/__tests__/QueryManager/index.ts | 18 +----------------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/core/QueryInfo.ts b/src/core/QueryInfo.ts index 02e1768af17..eff8a66139a 100644 --- a/src/core/QueryInfo.ts +++ b/src/core/QueryInfo.ts @@ -184,6 +184,17 @@ export class QueryInfo { diff: Cache.DiffResult | null, options?: Cache.DiffOptions ) { + // some very long comment about feuds + if ( + diff && + !diff.complete && + this.lastDiff && + this.lastDiff.diff.complete && + this.lastWrite && + this.lastWrite.dmCount === destructiveMethodCounts.get(this.cache) + ) { + return; + } this.lastDiff = diff ? { diff --git a/src/core/__tests__/QueryManager/index.ts b/src/core/__tests__/QueryManager/index.ts index 9a958b7ccd8..c8742d8f0eb 100644 --- a/src/core/__tests__/QueryManager/index.ts +++ b/src/core/__tests__/QueryManager/index.ts @@ -2397,23 +2397,7 @@ describe("QueryManager", () => { }, }, }); - } else if (count === 3) { - expect(result).toEqual({ - loading: true, - networkStatus: NetworkStatus.loading, - data: { - info: {}, - }, - partial: true, - }); - } else if (count === 4) { - expect(result).toEqual({ - loading: false, - networkStatus: NetworkStatus.ready, - data: { - info: {}, - }, - }); + setTimeout(resolve, 100); } else { reject(new Error(`Unexpected ${JSON.stringify({ count, result })}`)); From b4100b28775233ff8ca5d902e20bc8c6e2d9fed9 Mon Sep 17 00:00:00 2001 From: Lenz Weber-Tronic Date: Thu, 14 Dec 2023 15:23:16 +0100 Subject: [PATCH 2/2] changeset --- .changeset/healthy-pets-allow.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/healthy-pets-allow.md diff --git a/.changeset/healthy-pets-allow.md b/.changeset/healthy-pets-allow.md new file mode 100644 index 00000000000..93002c5efa8 --- /dev/null +++ b/.changeset/healthy-pets-allow.md @@ -0,0 +1,5 @@ +--- +"@apollo/client": patch +--- + +Work around a potential feud when a `read` function is present on an entity with a non-normalizable child (#7028)