@hasInverse GraphQL to DQL mapping

ok that’s good enough.
Another question abiut the gap between GQL and DQL,
when I use, for example, the @hasInverse directive and look in Ratel on the schema, I can’t see the @reverse index under the relvante predicate.
Can you tell why it doesn’t be reflected?

1 Like

This is done purposefully. @hasInverse is not the equivalent to adding the @reverse directive in DQL. On the graphql schema, the @hasInverse directive creates logic in the resolvers to add/update/delete the inverse edge of the specified type. There is more to the underlying reasoning behind this but overall it is to allow for better type notatation predicate control. In DQL a single predicate can be applied between two types, but in GQL, if a Post Type has an author predicate and a Author Type has a hasPosts predicate, and they are linked with the @hasInverse, then the logic links Post.author <-> Author.hasPosts. In DQL this would be controlled without really specifying the edge on the opposite and assigning the @reverse which allows you to query with the ~ syntax such as ~author


This seems to be a common topic here in this community. @core-devs Is there any work for documentation that explains more of the differences like this between DQL and GQL? So far all I am seeing is:

And the docs for @hasInverse and @reverse don’t really help explain why the one is not equivalent to the other:

5 Likes