According to https://docs.dgraph.io/query-language/#recurse-query, you can specify only one level of predicates after root. And indeed, this query doesn’t return any results:
{
recursive(func: eq(name, "a")) @recurse {
child {
name
}
}
}
Firstly, this should actually error out, and it’s quite confusing that it doesn’t.
Secondly, I think it would be nice if we could just recurse on the top level predicates (as before), while still expanding the lower level predicates at each iteration. Of course, you can work around it by assigning the children to a variable and finding their names in another block, but I think it would be nicer if the above query gave us the full tree of children with their names.
If anyone wants to try, I tested this on 197e1d5e4cb642c81d833fb510c7758a1fff9ff6, with this data:
{
set {
_:a <name> "a" .
_:a <child> _:b .
_:b <name> "b" .
_:b <child> _:c .
_:c <name> "c" .
_:c <child> _:d .
_:d <name> "d" .
_:d <child> _:e .
_:e <name> "e" .
_:e <child> _:f .
_:f <name> "f" .
_:f <child> _:g .
}
}
and this schema:
name: string @index(exact) .
%s: uid @reverse .