From ea1b7464a28aaa2be4999b015a31253b2b553c2f Mon Sep 17 00:00:00 2001 From: Slava Kim Date: Tue, 12 Jul 2016 12:41:09 -0700 Subject: [PATCH] remove optimisticResponse property on mutation actions --- src/QueryManager.ts | 2 -- src/actions.ts | 1 - src/optimistic-data/store.ts | 3 +-- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/QueryManager.ts b/src/QueryManager.ts index 6af22ad8484..4156e0a5373 100644 --- a/src/QueryManager.ts +++ b/src/QueryManager.ts @@ -274,7 +274,6 @@ export class QueryManager { result, mutationId, resultBehaviors, - optimisticResponse, }); return result; @@ -285,7 +284,6 @@ export class QueryManager { error: err, mutationId, resultBehaviors, - optimisticResponse, }); return Promise.reject(err); diff --git a/src/actions.ts b/src/actions.ts index 831296c9f68..764331cf733 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -91,7 +91,6 @@ export interface MutationResultAction { type: 'APOLLO_MUTATION_RESULT'; result: GraphQLResult; mutationId: string; - optimisticResponse: Object; resultBehaviors?: MutationBehavior[]; } diff --git a/src/optimistic-data/store.ts b/src/optimistic-data/store.ts index abea9a284be..596e05b667c 100644 --- a/src/optimistic-data/store.ts +++ b/src/optimistic-data/store.ts @@ -37,7 +37,6 @@ export function optimistic( type: 'APOLLO_MUTATION_RESULT', result: { data: action.optimisticResponse }, mutationId: action.mutationId, - optimisticResponse: null, resultBehaviors: action.resultBehaviors, } as ApolloAction; @@ -64,7 +63,7 @@ export function optimistic( return newState; } else if ((isMutationErrorAction(action) || isMutationResultAction(action)) - && action.optimisticResponse) { + && previousState.some(change => change.mutationId === action.mutationId)) { // throw away optimistic changes of that particular mutation const newState = previousState.filter( (change) => change.mutationId !== action.mutationId);