Bundle mutations and rollback in case of error

When adding data in complex schemas, often you have side-effects that have to be accounted for.
This means that one mutation is often followed by several others. If one of these mutations fail, currently the client has to check every mutation for errors and roll-back all previous ones.

It would be great if mutations could be bundled instead and rolled back automatically if an error occurs on one of them.

What do you think?

Hi @maaft ,

Yes, this feature of combining mutations in a single transaction has been requested before. We have an RFC for this over here, Transactions in GraphQL . This is also a part of our roadmap and we plan on implementing this in coming months.

1 Like

Hi @rajas any updated one this?

Hi Rohan,

This feature was implemented quite some time back with v21.03.

Users can now run a set of mutations within a “Transaction” and choose to either commit or abort them using the /commit?startTs= and the commit?startTs=&abort=true endpoints respectively.

Please refer the docs for more info.

https://dgraph.io/docs/dql/clients/raw-http/#start-a-transaction

Hi @rarvikar
Thank you for sharing. Does this work with graphql or only raw http?

TIA

This is only supported with DQL as of today. All gRPC clients support transactions too, apart from raw HTTP.