From 8e8e82fd77de2a4d7f1ab38eb44fefff9b8a87cc Mon Sep 17 00:00:00 2001 From: Shadaj Laddad Date: Mon, 10 Jul 2017 15:30:34 -0700 Subject: [PATCH] Add support for devtools with new query and mutations store location --- src/ApolloClient.ts | 10 ++++++++-- src/core/QueryManager.ts | 2 +- src/mutations/store.ts | 4 ++++ src/queries/store.ts | 4 ++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/ApolloClient.ts b/src/ApolloClient.ts index d0737c7d26d..30b6dfdf992 100644 --- a/src/ApolloClient.ts +++ b/src/ApolloClient.ts @@ -445,7 +445,10 @@ export default class ApolloClient implements DataProxy { if (this.devToolsHookCb) { this.devToolsHookCb({ action, - state: this.queryManager.getApolloState(), + state: { + queries: this.queryManager.queryStore.__getStore(), + mutations: this.queryManager.mutationStore.__getStore(), + }, dataWithOptimisticResults: this.queryManager.getDataWithOptimisticResults(), }); } @@ -484,7 +487,10 @@ export default class ApolloClient implements DataProxy { if (this.devToolsHookCb) { this.devToolsHookCb({ action, - state: this.queryManager.getApolloState(), + state: { + queries: this.queryManager.queryStore.__getStore(), + mutations: this.queryManager.mutationStore.__getStore(), + }, dataWithOptimisticResults: this.queryManager.getDataWithOptimisticResults(), }); } diff --git a/src/core/QueryManager.ts b/src/core/QueryManager.ts index 86021bdb42a..a8077ec28e9 100644 --- a/src/core/QueryManager.ts +++ b/src/core/QueryManager.ts @@ -456,7 +456,7 @@ export class QueryManager { variables, isPoll: fetchType === FetchType.poll, isRefetch: fetchType === FetchType.refetch, - metadata, fetchMoreForQueryId + metadata, fetchMoreForQueryId, }); this.broadcastQueries(); diff --git a/src/mutations/store.ts b/src/mutations/store.ts index f17eafaf8e2..5ee4f28e1a7 100644 --- a/src/mutations/store.ts +++ b/src/mutations/store.ts @@ -1,6 +1,10 @@ export class MutationStore { private store: {[mutationId: string]: MutationStoreValue} = {}; + public __getStore(): {[mutationId: string]: MutationStoreValue} { + return this.store; + } + public get(mutationId: string): MutationStoreValue { return this.store[mutationId]; } diff --git a/src/queries/store.ts b/src/queries/store.ts index 7c569e80911..03640d85e58 100644 --- a/src/queries/store.ts +++ b/src/queries/store.ts @@ -16,6 +16,10 @@ import { NetworkStatus } from './networkStatus'; export class QueryStore { private store: {[queryId: string]: QueryStoreValue} = {}; + public __getStore(): {[queryId: string]: QueryStoreValue} { + return this.store; + } + public get(queryId: string): QueryStoreValue { return this.store[queryId]; }