Skip to content
This repository has been archived by the owner on May 10, 2022. It is now read-only.

Commit

Permalink
Merge pull request #4 from mixcloud/gd-mutation-errors
Browse files Browse the repository at this point in the history
Reject mutation onFailure with the error message
  • Loading branch information
sdcooke authored Apr 7, 2017
2 parents 3294108 + 433686f commit ed36ba0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/__tests__/testMutate.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ describe('mutate', () => {
it('should return a promise and handle onFailure', () => {
return new Promise(resolve => {
mutate({}, {}).then(null, resolve);
Relay.mutations[0].args[4].onFailure();
Relay.mutations[0].args[4].onFailure({getError: () => "Error message"});
}).then((error) => {
expect(error).toBe("Error message");
});
});
});
2 changes: 1 addition & 1 deletion src/mutate.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function mutate(env: Relay.Environment, config: MutationConfig):
return new Promise((resolve, reject) => {
const mutation = new Relay.GraphQLMutation(query, variables, files, env, {
onSuccess: resolve,
onFailure: reject
onFailure: (transaction) => reject(transaction.getError())
});
if (optimisticResponse) {
mutation.applyOptimistic(query, optimisticResponse, configs);
Expand Down

0 comments on commit ed36ba0

Please sign in to comment.