You’re starting off with a GraphQL schema using @hasInverse where the inverse relationships are maintained in GraphQL mutations. Because you ran a DQL mutation, the @hasInverse GraphQL directive doesn’t apply. If you run a GraphQL mutation, then you’ll see your inverse relationships.
Say we start with your GraphQL schema (with “name”, not “ame”, for the Company type):
type Person {
name: String!
employers: [Company] @hasInverse(field: "employees")
}
type Company {
name: String! @search(by: [hash])
employees: [Person] @hasInverse(field: "employers")
}
Then I can run this GraphQL mutation and see the response of this mutation have the relationship from Carol to Google and back to Carol:
mutation {
addPerson(input: [
{
name: "Carol",
employers: [
{
name: "Google"
}
]
}
]) {
person {
name
employers {
name
employees {
name
}
}
}
}
}
The @reverse in DQL does not behave the same syntactically as @hasInverse in GraphQL.
You can either A) use the reverse predicate on employees and then query under Person for ~employees or B) when create an edge manually create the inverse:
No automatic inverse edges are created in DQL, but the reverse directive does allow you to use the same predicate in both directions using the ~ syntax to indicate the reverse direction.
This definitely needs to be in the docs somewhere—pretty big gotcha!
EDIT: I think what needs to be more obvious is that DQL isn’t merely a different syntax, but there is insertion logic that isn’t applied when you use DQL. Clear to me why this is, but wasn’t obvious in the beginning.