Skip to content

Commit

Permalink
fix bugs in the previous commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Slava committed Jul 12, 2016
1 parent 2cb6bca commit 389080e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/QueryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ export class QueryManager {
// this will throw an error if there are missing fields in
// the results if returnPartialData is false.
resultFromStore = readSelectionSetFromStore({
store: this.getDataWithOptimisticResults(),
store: this.getApolloState().data,
rootId: querySS.id,
selectionSet: querySS.selectionSet,
variables,
Expand Down
2 changes: 1 addition & 1 deletion src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,5 @@ export interface ApolloReducerConfig {

export function getDataWithOptimisticResults(store: Store): NormalizedCache {
const patches = store.optimistic.map(opt => opt.data);
return assign(store.data, ...patches) as NormalizedCache;
return assign({}, store.data, ...patches) as NormalizedCache;
}
4 changes: 2 additions & 2 deletions test/optimistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@ describe('optimistic mutation results', () => {
optimisticResponse: optimisticResponse2,
resultBehaviors,
}).then((res) => {
checkBothMutationsAreApplied('This one was created with a mutation.', 'second mutation.');
checkBothMutationsAreApplied('This one was created with a mutation.', 'Second mutation.');
const mutationsState = client.store.getState().apollo.mutations;
assert.equal(mutationsState[2].loading, false);
assert.equal(mutationsState[3].loading, false);
Expand All @@ -625,7 +625,7 @@ describe('optimistic mutation results', () => {
return Promise.all([promise, promise2]);
})
.then(() => {
checkBothMutationsAreApplied('This one was created with a mutation.', 'second mutation.');
checkBothMutationsAreApplied('This one was created with a mutation.', 'Second mutation.');
});
});
});
Expand Down

0 comments on commit 389080e

Please sign in to comment.