Dgraph DQL Tour
Var Blocks
GroupBy
A groupby
query aggregates query results given a set of properties on which to
group elements. For example, a query containing the block
director.film @groupby(genre) {
a as count(uid)
}
finds nodes reachable along the director.film
edge, partitions these into
groups based on genre, then counts how many nodes are in each group.
Inside a groupby
block, only aggregations are allowed and count
can only be
applied to uid
.
The result is the grouped edges and the value variables for the aggregations.
In this case the value variable is a map from genres to values.
Often, it’s necessary to use groupby
with another query to obtain values other
than aggregations.