Skip to content

Commit

Permalink
Avoid initial NetworkStatus.poll for watched queries.
Browse files Browse the repository at this point in the history
In commit 6e0135d (part of PR apollographql#5565) I
added a this.queryStore.initQuery call to the QueryManager#watchQuery
method, to ensure the queryStore has information about watched queries as
early as possible. However, I mistakenly copied the isPoll option value
from the initQuery call site in fetchQuery, which caused some watched
queries (those that use polling) to have NetworkStatus.poll instead of
NetworkStatus.loading before any network activity had occurred. This
commit fixes that problem by always passing isPoll:false in watchQuery,
regardless of whether options.pollInterval is defined.
  • Loading branch information
benjamn committed Nov 21, 2019
1 parent 711df10 commit 2e3a529
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,11 @@ export class QueryManager<TStore> {
document: this.transform(options.query).document,
variables: options.variables,
storePreviousVariables: false,
isPoll: typeof options.pollInterval === 'number',
// Even if options.pollInterval is a number, we have not started
// polling this query yet (and we have not yet performed the first
// fetch), so NetworkStatus.loading (not NetworkStatus.poll or
// NetworkStatus.refetch) is the appropriate status for now.
isPoll: false,
isRefetch: false,
metadata: options.metadata,
fetchMoreForQueryId: void 0,
Expand Down

0 comments on commit 2e3a529

Please sign in to comment.