Skip to content

Commit

Permalink
Add support for devtools with new query and mutations store location
Browse files Browse the repository at this point in the history
  • Loading branch information
shadaj committed Jul 10, 2017
1 parent 0cfc9a1 commit 4f1fee8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/ApolloClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
}
Expand Down Expand Up @@ -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(),
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ export class QueryManager {
variables,
isPoll: fetchType === FetchType.poll,
isRefetch: fetchType === FetchType.refetch,
metadata, fetchMoreForQueryId
metadata, fetchMoreForQueryId,
});

this.broadcastQueries();
Expand Down
4 changes: 4 additions & 0 deletions src/mutations/store.ts
Original file line number Diff line number Diff line change
@@ -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];
}
Expand Down
4 changes: 4 additions & 0 deletions src/queries/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 4f1fee8

Please sign in to comment.