Skip to content

Commit

Permalink
Ensure all relevant cache.diff options preserved in broadcastWatch.
Browse files Browse the repository at this point in the history
Both `returnPartialData` and `canonizeResults` were missing from this
call. Instead of enumerating the properties, we can take advantage of
the overlap between `WatchOptions` and `DiffOptions` to pass all
properties through, without having to enumerate them explicitly, so this
kind of mistake won't happen again.

Fixes #8831.
  • Loading branch information
benjamn committed Sep 23, 2021
1 parent a4b03cd commit 6839601
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,17 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
c: Cache.WatchOptions,
options?: BroadcastOptions,
) {
const { lastDiff } = c;
const diff = this.diff<any>({
query: c.query,
variables: c.variables,
optimistic: c.optimistic,
});
const {
lastDiff,
// WatchOptions extends ReadOptions (adding a few fields like lastDiff),
// so the ...rest object of this destructuring is a ReadOptions object.
...readOptions
} = c;

// DiffOptions also extends ReadOptions, and currently requires no extra
// properties, so we can use readOptions as DiffOptions, without having to
// enumerate the relevant properties (query, variables, etc.) explicitly.
const diff = this.diff<any>(readOptions);

if (options) {
if (c.optimistic &&
Expand Down

0 comments on commit 6839601

Please sign in to comment.