Skip to content

Commit

Permalink
Revert "Check structural equality in QueryInfo#setDiff. (#6891)"
Browse files Browse the repository at this point in the history
This reverts commit 24a4396, which
prevented some legitimate updates in https://studio.apollographql.com.
We will have to keep investigating #6888 to find a better solution.
  • Loading branch information
benjamn committed Aug 28, 2020
1 parent 4908ad7 commit c2ef68f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

## Bug Fixes

- Check structural equality of diff results in `QueryInfo#setDiff` instead of reference equality. <br/>
[@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. <br/>
[@benjamn](https://github.com/benjamn) in [#6893](https://github.com/apollographql/apollo-client/pull/6893)

Expand Down
12 changes: 10 additions & 2 deletions src/__tests__/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -3079,19 +3081,25 @@ 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([
{ a: 123, b: "asdf" },
{ 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([
Expand Down
3 changes: 1 addition & 2 deletions src/core/QueryInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c2ef68f

Please sign in to comment.