Skip to content

Commit e8d2536

Browse files
committed
Remove cache.batch wrapping, since we no longer need onWatchUpdated.
1 parent 9c06299 commit e8d2536

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

src/core/ObservableQuery.ts

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -405,46 +405,36 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`);
405405
combinedOptions,
406406
NetworkStatus.fetchMore,
407407
).then(fetchMoreResult => {
408-
409408
this.queryManager.removeQuery(qid);
410409

411410
if (queryInfo.networkStatus === NetworkStatus.fetchMore) {
412411
queryInfo.networkStatus = originalNetworkStatus;
413412
}
414413

415-
// Performing this cache update inside a cache.batch transaction ensures
416-
// any affected cache.watch watchers are notified about the updates. Most
417-
// watchers will be using the QueryInfo class, which responds to
418-
// notifications by calling reobserveCacheFirst to deliver fetchMore cache
419-
// results back to this ObservableQuery.
420-
this.queryManager.cache.batch({
421-
update: cache => {
422-
const { updateQuery } = fetchMoreOptions;
423-
if (updateQuery) {
424-
cache.updateQuery({
425-
query: this.options.query,
426-
variables: this.variables,
427-
returnPartialData: true,
428-
optimistic: false,
429-
}, previous => updateQuery(previous!, {
430-
fetchMoreResult: fetchMoreResult.data,
431-
variables: combinedOptions.variables as TFetchVars,
432-
}));
433-
434-
} else {
435-
// If we're using a field policy instead of updateQuery, the only
436-
// thing we need to do is write the new data to the cache using
437-
// combinedOptions.variables (instead of this.variables, which is
438-
// what this.updateQuery uses, because it works by abusing the
439-
// original field value, keyed by the original variables).
440-
cache.writeQuery({
441-
query: combinedOptions.query,
442-
variables: combinedOptions.variables,
443-
data: fetchMoreResult.data,
444-
});
445-
}
446-
},
447-
});
414+
const { updateQuery } = fetchMoreOptions;
415+
if (updateQuery) {
416+
this.queryManager.cache.updateQuery({
417+
query: this.options.query,
418+
variables: this.variables,
419+
returnPartialData: true,
420+
optimistic: false,
421+
}, previous => updateQuery(previous!, {
422+
fetchMoreResult: fetchMoreResult.data,
423+
variables: combinedOptions.variables as TFetchVars,
424+
}));
425+
426+
} else {
427+
// If we're using a field policy instead of updateQuery, the only
428+
// thing we need to do is write the new data to the cache using
429+
// combinedOptions.variables (instead of this.variables, which is
430+
// what this.updateQuery uses, because it works by abusing the
431+
// original field value, keyed by the original variables).
432+
this.queryManager.cache.writeQuery({
433+
query: combinedOptions.query,
434+
variables: combinedOptions.variables,
435+
data: fetchMoreResult.data,
436+
});
437+
}
448438

449439
return fetchMoreResult as ApolloQueryResult<TFetchData>;
450440
});

0 commit comments

Comments
 (0)