I have a single instance of Dgraph that I use for both DQL and GraphQL queries, and I define both schema types. In general this works well, but i have an issue making reverse edges work nicely across both.
In DQL it is simple, i can link TypeA to TypeB with a TypeA.owns edge, with an @reverse directive. This results in a single predicate on TypeA, and i can navigate from TypeB to TypeA with ~TypeA.owns query.
For the GraphQL schema, I can reuse the outbound edge predicate with
owns: [TypeB] on TypeA, as it reuses the existing TypeA.owns predicate from DQL schema. However, for the reverse edge it seems I have to add an extra predicate to my schema.
~owns: [TypeB] @dgraph(pred: "~TypeA.owns") is invalid syntax as ~ is not allowed.
My current solution is to have
owns: [TypeB] @hasInverse(field: ownedBy) on TypeA and
ownedBy: [TypeA] on TypeB. I’d prefer to avoid this as it is simpler to use the owns and ~owns construct in DQL, and leave dgraph to manage the creation of reverse edges etc. Is there some way to acheive this without the extra predicate?