-
Notifications
You must be signed in to change notification settings - Fork 54
Aggregation Queries
Igor Dianov edited this page May 29, 2024
·
2 revisions
You can fetch aggregations on entity fields/relationship groups using an aggregation query.
The name of the aggregate field is of the form aggregate
as part of the select queryr
The currently supported aggregation functions are count. Aggregation support for other functions sum, avg, max, min, etc. will be added soon.
{
Books {
aggregate {
count
}
}
}
{
"data": {
"Books": {
"aggregate": {
"count": 5
}
}
}
}
{
Books {
aggregate {
count
by {
author {
by(field: name)
count
}
}
}
}
}
{
"data": {
"Books": {
"aggregate": {
"count": 5,
"by": {
"author": [
{
"by": "Anton Chekhov",
"count": 3
},
{
"by": "Leo Tolstoy",
"count": 2
}
]
}
}
}
}
}