I am exploring dgraph and have noob question:
I am representing a tree using dgraph. How do I get a subtree ie. recursively get all children of a uid?
I populated the following json data using the mutate api:
{
"set": [
{
"jungle": {
"animals": {
"lion": {
"name": "Simba"
},
"elephant": {
"name": "Ele"
}
},
"birds":{
"parrot": {
"name": "Zuzu"
},
"chicken": {
"name": "Chica"
}
}
}
}
]
}
after which I queried:
{
parent as p(func: has(animals)){
}
me(func: uid(parent)) @recurse(depth: 10, loop: true){
uid
expand(_all_)
}
}
I get:
{
"p": [],
"me": [
{
"uid": "0x3c",
"animals": [
{
"uid": "0x3d"
}
],
"birds": [
{
"uid": "0x40"
}
]
}
]
}
It looks like I am doing it wrong. Why it doesn’t return leaf nodes (parrot, chicken etc) with their names?
Thanks