From 2e3a52959bd257d1d5d82703518da14950a693c2 Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Thu, 21 Nov 2019 10:35:35 -0500 Subject: [PATCH] Avoid initial NetworkStatus.poll for watched queries. In commit 6e0135d24a5b995e2cfe6dd26693021bb85cceed (part of PR #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. --- src/core/QueryManager.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts index c725346d172..413f15bb0f5 100644 --- a/src/core/QueryManager.ts +++ b/src/core/QueryManager.ts @@ -776,7 +776,11 @@ export class QueryManager { 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,