Skip to content

Commit 380886f

Browse files
SlavaSashko Stubailo
authored andcommitted
Handle mutation error in reducers
1 parent 3219bec commit 380886f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/mutations/store.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
ApolloAction,
33
isMutationInitAction,
44
isMutationResultAction,
5+
isMutationErrorAction,
56
isStoreResetAction,
67
} from '../actions';
78

@@ -60,6 +61,13 @@ export function mutations(
6061
}) as MutationStoreValue;
6162

6263
return newState;
64+
} else if (isMutationErrorAction(action)) {
65+
const newState = assign({}, previousState) as MutationStore;
66+
67+
newState[action.mutationId] = assign({}, previousState[action.mutationId], {
68+
loading: false,
69+
error: action.error,
70+
}) as MutationStoreValue;
6371
} else if (isStoreResetAction(action)) {
6472
// if we are resetting the store, we no longer need information about the mutations
6573
// that are currently in the store so we can just throw them all away.

0 commit comments

Comments
 (0)