Do any of the graph based/aware databases have good mechanisms for maintaining referential integrity?
Only allow creation of a comment if an edge is created to link this comment to a post at the same time.


This is supported by Dgraph Labs' GraphQL implementation out of the box. In your schema, you would add a exclamation mark ! to denote that an edge is required when added and when retrieved.
type Post {
  id: ID
  comments: [Comment]
}
type Comment {
  id: ID
  text: String!
  onPost: Post! @hasInverse(field: comments)
}

This schema above, would mandate that every Comment have a reference onPost edge and would return errors if you send mutations that did not match this requirement.
This would also error if you were to query a comment and request the onPost edge and it did not exist. How might that happen if the Comments cannot be added without the edge? Because the @hasInverse will do the bookkeeping to keep the Post.comments and Comment.onPost edges consistent. This allows you to delete a post node that could delete Comment.onPost edges.


Prevent deletion of a post while there are edges from comments to this post.
Prevent deletion of an edge from a comment to a post without deleting the comment itself


Right now in Dgraph's GraphQL implementation there is no way to enforce or prevent cascade deletes as there is with SQL-like databases. This would have to be managed from a middleware level. Having that said, Dgraph Labs has implemented a way to currently do this with the @custom directive and are currently developing (promised for 20.11 release) a @lambda directive to enable an almost native javascript middleware functionality. Combining either one of these methods with another currently awaiting release directive @generate. The generate directive will allow you to disable the default generated mutations and then you can create your own custom mutations to handle this business logic as needed with DQL upserts. These custom mutations can then be mapped and served via the GraphQL endpoint.