I’m using dgraph to store tree data structure. Here is my graphql schema.
type Node {
title: String!
parent: PalaceNode
children: [PalaceNode] @hasInverse(field: parent)
}
I want to fetch all ancestors for a node.
query getNodeAncestors($id: ID!) {
getNode(id: $id) {
parent {
id
title
}
}
}
I dont know at what level this node will be so i can not add many nested parent blocks and even if a knew that would be ugly. So is there a way to fetch all ancestors of a node? Is there any recursive functionality in dgraph’s graphql?