`@reverse` with custom field on inverse relation

@hasInverse can link fields with different names, i.e. Post.author <-> Author.hasPosts

But I’m seeing that the @reverse directive forces you to use the same name on both sides, i.e. author <-> ~author .

Is there a way to have @reverse use a different field name on the reverse relation, i.e author <-> ~hasPosts ?

No, cuz the reverse index is different from hasInverse in the GraphQL features. There’s no similar feature to hasInverse in DQL.

You can add an alias to it. Would that help?

An alias is one way, though I would prefer to not have to create it every time :slight_smile:

I’m new to the community - is there a reason why GQL and DQL differ in this way?

This deserves a longer answer, but for starters check out Back to GraphQL: Dgraph’s Life-long Journey with GraphQL - Dgraph Blog

1 Like