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) 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 })}`));