I am trying to set up retries, on failed mutations, as documented by Relay: https://facebook.github.io/relay/docs/api-reference-relay-container.html#getpendingtransactions.
I am causing the mutation to fail, on the graphql server, by returning an error:
mutateAndGetPayload: ({text}) => {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve(new Error("failed"));
}, 2 * 1000);
});
},
When I first execute the mutation I can see the status of 'COMMITTING'. But then in the next render getPendingTransactions returns null and I cannot figure out how to see a status of 'COMMIT_FAILED'.
var transactions = this.props.relay.getPendingTransactions(this.props.story);
console.log("TRANSACTIONS", transactions);
var transaction = transactions ? transactions[0] : null;
if (transaction) {
console.log("STATUS", transaction.getStatus());
}
I must be missing something, but so far can't figure it out.
Your transaction with a COMMIT_FAILED
will not be in pendingTransactions
since it has been tried and failed already. Are you mutating using RelayStore.update
?
You could try creating a transaction using RelayStore.apply_update
. This function actually returns the transaction object. You can then call transaction.commit()
. If it fails, your transaction object should have a status of COMMIT_FAILED
.