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 May 5, 2021
1 parent 8336923 commit baa3e51
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 { OptimisticWrapperFunction, wrap } from 'optimism';
import { equal } from '@wry/equality';

import { ApolloCache, BatchOptions } from '../core/cache';
import { Cache } from '../core/types/Cache';
Expand Down Expand Up @@ -499,7 +500,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 baa3e51

Please sign in to comment.