diff --git a/packages/apollo-client/src/ApolloClient.ts b/packages/apollo-client/src/ApolloClient.ts index b03485013d1..3bcbd58c352 100644 --- a/packages/apollo-client/src/ApolloClient.ts +++ b/packages/apollo-client/src/ApolloClient.ts @@ -273,9 +273,7 @@ export default class ApolloClient implements DataProxy { * to dispose of this `ApolloClient` instance. */ public stop() { - if (this.queryManager) { - this.queryManager.stop(); - } + this.queryManager.stop(); } /** @@ -505,29 +503,18 @@ export default class ApolloClient implements DataProxy { */ public resetStore(): Promise[] | null> { return Promise.resolve() - .then(() => { - return this.queryManager - ? this.queryManager.clearStore() - : Promise.resolve(null); - }) + .then(() => this.queryManager.clearStore()) .then(() => Promise.all(this.resetStoreCallbacks.map(fn => fn()))) - .then(() => { - return this.queryManager && this.queryManager.reFetchObservableQueries - ? this.queryManager.reFetchObservableQueries() - : Promise.resolve(null); - }); + .then(() => this.queryManager.reFetchObservableQueries()); } /** * Remove all data from the store. Unlike `resetStore`, `clearStore` will * not refetch any active queries. */ - public clearStore(): Promise { - const { queryManager } = this; + public clearStore(): Promise { return Promise.resolve() - .then(() => - queryManager ? queryManager.clearStore() : Promise.resolve(null), - ) + .then(() => this.queryManager.clearStore()) .then(() => Promise.all(this.clearStoreCallbacks.map(fn => fn()))); } @@ -570,9 +557,7 @@ export default class ApolloClient implements DataProxy { public reFetchObservableQueries( includeStandby?: boolean, ): Promise[]> | Promise { - return this.queryManager - ? this.queryManager.reFetchObservableQueries(includeStandby) - : Promise.resolve(null); + return this.queryManager.reFetchObservableQueries(includeStandby); } /** diff --git a/packages/apollo-client/src/__tests__/client.ts b/packages/apollo-client/src/__tests__/client.ts index ff0342d95de..2abf96b5138 100644 --- a/packages/apollo-client/src/__tests__/client.ts +++ b/packages/apollo-client/src/__tests__/client.ts @@ -2296,6 +2296,7 @@ describe('client', () => { cache: new InMemoryCache(), }); client.queryManager = { + reFetchObservableQueries() {}, clearStore: () => { done(); },