hasInverse and how its different from using @reverse on predicates

I hit the same challenge here: Reverse Edges when using both DQL and GraphQL . For my application I had to stop using reverse edges, and instead managed the inverse predicates myself. This works fine in both GraphQL and DQL, but has some code overhead, and has some side effects (e.g. I also now need to duplicate all the facets, reverse edges store facets once for both directions). I’d therefore love for this to be “unified” in Dgraph across both schema types.

I think it could be acheived by allowing reverse edges in DQL to have a defined alias? I.e. instead of owns and ~owns, we alias ~owns to ownedBy? Then we could do @hasInverse(field: ownedBy) in the GraphQL schema. Behind the scenes ownedBy could still operate as a reverse edge, i.e. be auto generated and shares facets with owns.

1 Like