Skip to content

Commit

Permalink
fix(): fix ObservableQuery.lifecycle for cache only results
Browse files Browse the repository at this point in the history
  • Loading branch information
blaugold committed Nov 30, 2020
1 parent 2efce9f commit f44b479
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions packages/graphql/lib/src/core/observable_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,16 @@ class ObservableQuery {
queryManager.fetchQueryAsMultiSourceResult(queryId, options);
latestResult ??= allResults.eagerResult;

// if onData callbacks have been registered,
// they are waited on by default
lifecycle = _onDataCallbacks.isNotEmpty
? QueryLifecycle.sideEffectsPending
: QueryLifecycle.pending;
if (allResults.networkResult == null) {
// This path is only possible for cacheFirst and cacheOnly fetch policies.
lifecycle = QueryLifecycle.completed;
} else {
// if onData callbacks have been registered,
// they are waited on by default
lifecycle = _onDataCallbacks.isNotEmpty
? QueryLifecycle.sideEffectsPending
: QueryLifecycle.pending;
}

if (options.pollInterval != null && options.pollInterval > Duration.zero) {
startPolling(options.pollInterval);
Expand Down

0 comments on commit f44b479

Please sign in to comment.