Aggregation Queries
Aggregate fields
You can fetch aggregations on columns along with nodes using an aggregation query.
The name of the aggregate field is of the form <field-name>Aggregate
.
Common aggregation functions are count
, sum
, avg
, max
, min
, etc. You can see the complete specification of the
aggregate field in the metadata reference. Note that not all
aggregation functions are available for all data types.
Fetch aggregated data of an object
Example: Fetch a list of posts with aggregated data:
Fetch aggregated data on nested objects
The following is an example of a nested object query with aggregations on the array relationship between a user and posts.
Example: Fetch user with an id
of 1
and a nested list of posts with aggregated data: