Cycle detection and rollback

I need to implement the following behavior.

  1. Begin transaction
  2. Upsert the graph (add a few nodes and relationships between those nodes and existing nodes)
  3. Detect if a cycle was added as a result of 2
  4. If cycle then rollback
  5. If not then commit the transaction

Is Dgraph capable of implementing that behavior?

Thanks,
Michael-

Not exactly. There isn’t a way to check a cycle if the transaction wasn’t commited.
And there’s no Rollback. The transaction’s “fine tune/features***” in Dgraph is for internal use only. Dgraph controls what should be rejected, what has conflicts, etc. These things are not exposed to the user.

@mburbidg,

Are you attempting this with GraphQL or via dgo or another client?

Whoa… what?!?

Then why is transaction handling offered in clients if its meant for internal only?

https://dgraph.io/docs/clients/javascript/grpc/#creating-a-transaction

Is this something going away from the clients in a future version?

Anthony, sometimes you lack interpretation. I know exactly what’s available to the end user. I’ve been using Dgraph since 2017. You can assume from this that my phrases are more related to the finer control of a transaction. Which is what Michael is looking for.

There is no Rollback, and there is no checking cycle on the fly(But there is conflict checking on the fly with upsert directive). And it is not possible to query uncommitted transactions. And there’s also no way to introduce logic like “if not do this”. At least for now.