I'm am very interested by GraphQL for an analytic solution (think of an webapp displaying graphs). But I cannot find any examples of GraphQL using aggregate function. This is a main aspect of most of the queries done by my frontend.
For my solution, we have 3 typical backend calls.
- Search
- Aggregate
- Time Series
Let say we have this type specified in GraphQL
type Person {
name: String
age: Int
create_time: Date
}
- Search
This seems to be well handled by GraphQL. No question here.
ex. Search age of Person named Bob { Person(name: "Bob") { age } }
- Aggregate
This is the typical case where I want to display the info in a Pie Chart. So let say I want to count the number of person by age.
Here would be the PostgreSQL query:
SELECT age, count(*) from Ticket group by age;
What would be the equivalent in GraphQL?
- Time Series This is the typical case where I want to display the info in a BarChart with the X axis as time.
ex. Let say I want to count the number of created user per hour.
Here would be the PostgreSQL query:
SELECT date_trunc('hour', create_time) as create_time_bin, count(*) from Person group by create_time_bin order by create_time_bin ASC;
What would be the GraphQL equivalent query?