Dgraph DQL Tour
Query Variables in a child block
Query variables in a child block allow the query to carry answers matched at one level down to the children to filter against.
For example, take of the set of actors in all Jane Campion films; our challenge is to find which pairs in that set have acted together on a film not directed by Jane Campion.
The query here uses the sets of all Jane Campion’s films
JC_films and all
actors in any Jane Campion film
JC_actors in child blocks.
@cascade directive ensures answers match all parts of the query -
otherwise, actors who had no matching co-actors could be returned.
The query returns the trivial matches of actors and themselves as well as other coactors.
The same query could have been written using variables that span multiple queries, but the graph traversal would be the same.