Skip to content

Commit 3219bec

Browse files
SlavaSashko Stubailo
authored andcommitted
Add action APOLLO_MUTATION_ERROR
1 parent b0da570 commit 3219bec

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/QueryManager.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,16 @@ export class QueryManager {
268268
});
269269

270270
return result;
271+
})
272+
.catch((err) => {
273+
this.store.dispatch({
274+
type: 'APOLLO_MUTATION_ERROR',
275+
error: err,
276+
mutationId,
277+
resultBehaviors,
278+
});
271279

280+
return Promise.reject(err);
272281
});
273282
}
274283

@@ -685,7 +694,8 @@ export class QueryManager {
685694
});
686695

687696
this.removeFetchQueryPromise(requestId);
688-
reject(new ApolloError({
697+
698+
return Promise.reject(new ApolloError({
689699
networkError: error,
690700
}));
691701
});

src/actions.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,17 @@ export function isMutationResultAction(action: ApolloAction): action is Mutation
9696
return action.type === 'APOLLO_MUTATION_RESULT';
9797
}
9898

99+
export interface MutationErrorAction {
100+
type: 'APOLLO_MUTATION_ERROR';
101+
error: Error;
102+
mutationId: string;
103+
resultBehaviors?: MutationBehavior[];
104+
};
105+
106+
export function isMutationErrorAction(action: ApolloAction): action is MutationErrorAction {
107+
return action.type === 'APOLLO_MUTATION_ERROR';
108+
}
109+
99110
export interface StoreResetAction {
100111
type: 'APOLLO_STORE_RESET';
101112
observableQueryIds: string[];
@@ -113,4 +124,5 @@ export type ApolloAction =
113124
QueryStopAction |
114125
MutationInitAction |
115126
MutationResultAction |
127+
MutationErrorAction |
116128
StoreResetAction;

0 commit comments

Comments
 (0)