This is one of the confusing things about Dgraph. If you interact via DQL there is no typesafety, only when you interact with the database via GraphQL is the schema enforced. So DQL is a dangerous tool like using raw SQL, so you really need to know exactly what you’re doing when you’re using and make sure you don’t modify your data so it no longer makes sense given your schema.
There are a few gotchas related to this too—when using hasInverse in GraphQL schema, the reverse edges are created automatically, however, if using DQL this won’t happen so you will need to make sure you always create the reverse edges.