Not sure I understand the question. But, let me take a guess. You want to find all the other people in the same class as this person? If so, you need a reverse edge on Class, and you can run:
{
person(id: <0x3e8efeb24ba23885>) {
Name
Description
Class {
~Class { Name, Description } # This would give you all people in the class.
}
}
}
Actually what I’m trying to do in general is build a richer schema on top of dgraph. The schema will have classes, properties (object is a literal), and relations (object is a uid). The schema will be modified by an admin through an application front-end, and each class (and property and relation) will have a UID in dgraph. Users, through normal activity, will then be creating and modifying entities, all of which have a class. In this case, the class “Person” is identified by UID <0xd59531fa5ba5372b>. I am building an API on top of Dgraph that modifies and accesses all of these entities in a simplified way, and the API endpoint “/entity/get/listByClass” will take in the UID of a class and return all entities with that class.
Rather than returning all of the entities with the same class as that person, I would like to return all entities with the class with UID <0xd59531fa5ba5372b>. Similar to your answer, but as the input I have available the class UID, not the person UID. I have defined a predicate called “Class” using the dgraph schema syntax, so I was hoping I could use that “Class” predicate I have defined to directly find all entities that exist in a triple: “[Entity] [Class] [UID from API]”
Does this help answer your question? Please let me know if I can clarify further. And as always, thanks for all of your help and what you guys are doing at Dgraph.
I just realized that @mrjn’s note was just one step removed from the query I needed. For anyone else trying to do the same thing, the answer was to declare a reverse edge in the dgraph schema with:
mutation {
schema {
Class: uid @reverse .
}
}
And then to query on the class ID (<0xd59531fa5ba5372b>), like this: