Closed ian closed 2 years ago
Just copy-pasting the discussion related to this issue:
thelinuxlich — We will group automatically if the user adds in the graphql query additional fields besides the common aggregations
query {
findNotes {
text
count(of: NoteFields.id)
}
}
Will automatically group by text, count(id)
Just added the 5 essential aggregations to Rel: count, max, sum, avg and min.
The codegen will generate a enum containing all fields of each model to input on count, and a enum containing all fields of number type(including scalars) for the other 4 aggregations.
If the user pass additional fields on query, Rel will automatically GROUP the result, example:
Query {
findTodos(filter: { a: { gt: 1 } }) {
a
sum(of: TodoFields.b)
}
}
Is equivalent to GROUP(a, sum(b))
Comparisons: