Dgraph DQL Tour
Basic
Cascade
The @cascade
directive removes any nodes that don’t have all matching edges in
the query.
Another use is to remove nodes where a filter inside a block returns no results.
In the query below, Dgraph returns all Michael’s friends, whether or not they own a pet.
{
michael_friends_with_pets(func: allofterms([email protected], "Michael")) {
name
age
friend {
[email protected]
owns_pet
}
}
}
With the @cascade
directive, friends of Michael that don’t own a pet are not
included in the result.
{
michael_friends_with_pets(func: allofterms([email protected], "Michael")) @cascade {
name
age
friend {
[email protected]
owns_pet
}
}
}
You can read more about @cascade
directive in our documentation site:
https://dgraph.io/docs/query-language/#cascade-directive