Transactions in GraphQL

The actual extensions will have to be more like…

type DgraphTxn {
  txnID : ...
  keys : [...]
}

...
...

data: {...}
extensions : { txn { ... } }

...
...

mutation @transaction(txn: $txn) {
 m1(...) {...}
 m2(...){...}
}

Then, we’d write an extension to ApolloLink that handles all the keys etc. and all a developer has to worry about is the txn ID, so

This will mean open a new transaction, do m1 and m2, then commit. otherwise fail all.

mutation @transaction(commit: true) {
 m1(...) {...}
 m2(...){...}
}

This will mean keep the transaction open and return the details in the extensions

mutation @transaction {
 m1(...) {...}
 m2(...){...}
}

This one is continue txn 2 and then commit at end

mutation @transaction(id: 2, commit: true) {
 m1(...) {...}
 m2(...){...}
}

this means continue txn 2, but don’t commit

mutation @transaction(id: 2) {
 m1(...) {...}
 m2(...){...}
}

this is abort txn 2

mutation @transaction(id: 2) {
  abort {...}
}