Support of aggregate function in GraphQL -
i'm interested graphql analytic solution (think of webapp displaying graphs). cannot find examples of graphql using aggregate function. main aspect of of queries done frontend.
for solution, have 3 typical backend calls.
- search
- aggregate
- time series
let have type specified in graphql
type person { name: string age: int create_time: date }
- search
this seems handled graphql. no question here.
ex. search age of person named bob { person(name: "bob") { age } }
- aggregate
this typical case want display info in pie chart. let want count number of person age.
here postgresql query:
select age, count(*) ticket group age;
what equivalent in graphql?
- time series typical case want display info in barchart x axis time.
ex. let want count number of created user per hour.
here postgresql query:
select date_trunc('hour', create_time) create_time_bin, count(*) person group create_time_bin order create_time_bin asc;
what graphql equivalent query?
graphql, @ end of day, responds defined types. need put data type. whether specific type these different queries, or fields data on existing types, it's that's boils down to. graphql require more effort front in terms of defining types , queries return, makes more rigid, idea on other side of lies cool features, introspection , type checking. if doesn't seem make logical sense put sort of "ad hoc" data structures graphql type, it's not illegal have non-graphql endpoints if need other data sources.
Comments
Post a Comment