Aggregate queries
Aggregate queries in GraphQL are useful for summarizing data in various ways. They help in performing operations such as counting the number of records, summing up numerical fields, and grouping data based on specific fields.
Add _aggregate
with any asset type to perform aggregate queries. _count
, _sum
and _groupby
are currently supported.
Count Query
The count
query allows you to count the number of records that match a specific condition.
Example:
In this example, the query counts the invoices a 'updated' status.
Sum Query
The sum
query allows you to sum the values of a specific numerical field across all records that match a given condition.
Example:
In this example, the query sums up the amount of all invoices that have a 'updated' status.
Group By Query
The groupBy
query allows you to group records by a specific field and perform aggregate functions like count or sum within each group.
Example:
This query groups invoices by their type and provides the count of the invoices with 'updated' status.
Last updated