Skip to content

Commit

Permalink
Use deep equality check before calling watch.callback.
Browse files Browse the repository at this point in the history
Similar to #7997, but further upstream.
  • Loading branch information
benjamn committed Apr 30, 2021
1 parent a452e05 commit 0572693
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import './fixPolyfills';

import { DocumentNode } from 'graphql';
import { wrap } from 'optimism';
import { equal } from '@wry/equality';

import { ApolloCache, BatchOptions } from '../core/cache';
import { Cache } from '../core/types/Cache';
Expand Down Expand Up @@ -488,7 +489,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
}
}

if (!lastDiff || lastDiff.result !== diff.result) {
if (!lastDiff || !equal(lastDiff.result, diff.result)) {
c.callback(c.lastDiff = diff, lastDiff);
}
}
Expand Down

0 comments on commit 0572693

Please sign in to comment.