@@ -229,14 +229,23 @@ export class QueryInfo {
229
229
if ( oq ) {
230
230
oq [ "queryInfo" ] = this ;
231
231
this . listeners . add ( this . oqListener = ( ) => {
232
- // If this.diff came from an optimistic transaction, deliver the current
233
- // cache data to the ObservableQuery, but don't perform a reobservation,
234
- // since oq.reobserveCacheFirst might make a network request, and we
235
- // don't want to trigger network requests for optimistic updates.
236
232
const diff = this . getDiff ( ) ;
237
233
if ( diff . fromOptimisticTransaction ) {
234
+ // If this diff came from an optimistic transaction, deliver the
235
+ // current cache data to the ObservableQuery, but don't perform a
236
+ // reobservation, since oq.reobserveCacheFirst might make a network
237
+ // request, and we never want to trigger network requests in the
238
+ // middle of optimistic updates.
238
239
oq [ "observe" ] ( ) ;
239
240
} else {
241
+ // Otherwise, make the ObservableQuery "reobserve" the latest data
242
+ // using a temporary fetch policy of "cache-first", so complete cache
243
+ // results have a chance to be delivered without triggering additional
244
+ // network requests, even when options.fetchPolicy is "network-only"
245
+ // or "cache-and-network". All other fetch policies are preserved by
246
+ // this method, and are handled by calling oq.reobserve(). If this
247
+ // reobservation is spurious, isDifferentFromLastResult still has a
248
+ // chance to catch it before delivery to ObservableQuery subscribers.
240
249
oq . reobserveCacheFirst ( ) ;
241
250
}
242
251
} ) ;
0 commit comments