From 8942220031ecf8589f84ff388b88f461808d6051 Mon Sep 17 00:00:00 2001 From: Chang Wang Date: Mon, 4 Feb 2019 16:04:36 -0500 Subject: [PATCH] Update comments to address fetchQueryRejectFns's change to a Map # Conflicts: # packages/apollo-client/src/core/QueryManager.ts --- packages/apollo-client/src/core/QueryManager.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/apollo-client/src/core/QueryManager.ts b/packages/apollo-client/src/core/QueryManager.ts index e177bfc614a..b4fa678cbc5 100644 --- a/packages/apollo-client/src/core/QueryManager.ts +++ b/packages/apollo-client/src/core/QueryManager.ts @@ -73,9 +73,11 @@ export class QueryManager { // subscriptions as well private queries: Map = new Map(); - // A set of Promise reject functions for fetchQuery promises that have not + // A map of Promise reject functions for fetchQuery promises that have not // yet been resolved, used to keep track of in-flight queries so that we can // reject them in case a destabilizing event occurs (e.g. Apollo store reset). + // The key is in the format of `query:${queryId}` or `fetchRequest:${queryId}`, + // depending on where the promise's rejection function was created from. private fetchQueryRejectFns = new Map(); // A map going from the name of a query to an observer issued for it by watchQuery. This is @@ -963,6 +965,10 @@ export class QueryManager { public removeQuery(queryId: string) { const { subscriptions } = this.getQuery(queryId); // teardown all links + // Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises + // that each add their reject functions to fetchQueryRejectFns. + // A query created with `QueryManager.query()` could trigger a `QueryManager.fetchRequest`. + // The same queryId could have two rejection fns for two promises this.fetchQueryRejectFns.delete(`query:${queryId}`); this.fetchQueryRejectFns.delete(`fetchRequest:${queryId}`); subscriptions.forEach(x => x.unsubscribe());