forked from relay-tools/relay-commit-mutation-promise
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (25 loc) · 764 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var Relay = require('react-relay');
function commitMutationPromise(environment, config) {
return new Promise(function (resolve, reject) {
Relay.commitMutation(
environment,
Object.assign(
{},
config,
{
onCompleted: function (payload, errors) {
if (errors) {
reject(errors[0]);
return;
}
resolve(payload);
},
onError: function (error) {
reject(error);
}
}
)
);
});
}
module.exports = commitMutationPromise;