Hi folks. I’m exploring DGraph’s GraphQL support (after doing the same with FaunaDB) and enjoying what I see. For context, I’ve read all of the DGraph GraphQL docs, and none of the GraphQL± docs.
I have a couple of use cases for an actual graph–document DAGs–and am interested in general thoughts and advice there. For a start, though, I’d like to make some cross-field, cross-type constraints.
If Dgraph supported GraphQL unions (how close is that?), then I’d want this:
- Root nodes are constrained: the parent is the entity that owns the tree, not another node; and the owning entity has a reference to that root.
- Branch nodes are constrained: the branch node’s parent is another node; and the parent node has a child reference to the branch)
Without unions, it’s similar:
- Root nodes are constrained: the parent node is empty, the owning entity is set, and the owning entity has a reference to the root.
- Branch nodes are constrained: the owning entity is empty, the parent node is set, and the parent node has a child reference to the branch.
It seems like cross-field constraints are possible by (ab?)using the @auth directives–intersecting the data constraint with the actual auth constraint. That (hack?) might even work cross-type if we have better control over transactions (which I saw are coming soon).
Any suggestions, thoughts, or pointers?