Sample Data:
{'title': 'Alpha', '_People': '*', 'age': 10}
{'title': 'Beta', '_People': '*', 'age': 20}
Relationship:
Alpha -(friend)> Beta
Query:
Fetch relationships of Alpha
query = """{
all (func: has(_People))
@filter(eq(title, Alpha)) {
uid
expand(_all_) {
uid
expand(_all_) {}
}
}
}"""
Properly gives: A → B
Fetch Relationships of Beta
query = """{
all (func: has(_People))
@filter(eq(title, Beta)) {
uid
expand(_all_) {
uid
expand(_all_) {}
}
}
}"""
Does not give B → A relationship
Hack that I already know, but its not efficient:
- Create 2 relationships for everything, eg.
A -> B
andB -> A