Why only allow one level of predicates after root in a recurse block?

Ok, I now understand the behaviour that you are expecting. I can confirm that recurse is working as expected. I will try to explain how to make it more clear.

{
    recursive(func: eq(name, "a")) @recurse(depth: 4) {
        children as child
        name
    }
}

The above query tries to expand upto 4 levels.

name="a"       Level 0
|
child, name    Level 1   (Here child would be b and name a corresponding to node at level 0)
|
child, name    Level 2   (Child being c and name b)
|
child, name    Level 3   (Child d and name c)
|
child, name    Level 4   (Child e and name d)

Name e would come at Level 5 here and the variable children stores the child nodes as b, c, d and e. You could use depth + 1 as you said.

1 Like