diff --git a/CHANGELOG.md b/CHANGELOG.md index 12badca40fb..5931b650972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,6 @@ ## Bug Fixes -- Check structural equality of diff results in `QueryInfo#setDiff` instead of reference equality.
- [@benjamn](https://github.com/benjamn) in [#6891](https://github.com/apollographql/apollo-client/pull/6891) - - Use `options.nextFetchPolicy` internally to restore original `FetchPolicy` after polling with `fetchPolicy: "network-only"`, so that polling does not interfere with normal query watching.
[@benjamn](https://github.com/benjamn) in [#6893](https://github.com/apollographql/apollo-client/pull/6893) diff --git a/src/__tests__/client.ts b/src/__tests__/client.ts index 812a36c2f1f..f015f25f7bf 100644 --- a/src/__tests__/client.ts +++ b/src/__tests__/client.ts @@ -3028,9 +3028,11 @@ describe('@connection', () => { client.cache.evict({ fieldName: "a" }); await wait(); - expect(checkLastResult(aResults, a456)).toBe(a456); + // The results are structurally the same, but the result objects have + // been recomputed for queries that involved the ROOT_QUERY.a field. + expect(checkLastResult(aResults, a456)).not.toBe(a456); expect(checkLastResult(bResults, bOyez)).toBe(bOyez); - expect(checkLastResult(abResults, a456bOyez)).toBe(a456bOyez); + expect(checkLastResult(abResults, a456bOyez)).not.toBe(a456bOyez); const cQuery = gql`{ c }`; // Passing cache-only as the fetchPolicy allows the { c: "see" } @@ -3079,12 +3081,16 @@ describe('@connection', () => { { a: 123 }, { a: 234 }, { a: 456 }, + // Delivered again because we explicitly called resetLastResults. + { a: 456 }, ]); expect(bResults).toEqual([ { b: "asdf" }, { b: "ASDF" }, { b: "oyez" }, + // Delivered again because we explicitly called resetLastResults. + { b: "oyez" }, ]); expect(abResults).toEqual([ @@ -3092,6 +3098,8 @@ describe('@connection', () => { { a: 234, b: "asdf" }, { a: 234, b: "ASDF" }, { a: 456, b: "oyez" }, + // Delivered again because we explicitly called resetLastResults. + { a: 456, b: "oyez" }, ]); expect(cResults).toEqual([ diff --git a/src/core/QueryInfo.ts b/src/core/QueryInfo.ts index 6ac61fede32..dff299889df 100644 --- a/src/core/QueryInfo.ts +++ b/src/core/QueryInfo.ts @@ -149,8 +149,7 @@ export class QueryInfo { const oldDiff = this.diff; this.diff = diff; if (!this.dirty && - !equal(oldDiff && oldDiff.result, - diff && diff.result)) { + (diff && diff.result) !== (oldDiff && oldDiff.result)) { this.dirty = true; if (!this.notifyTimeout) { this.notifyTimeout = setTimeout(() => this.notify(), 0);