Can graphql return aggregate counts?

前端 未结 5 1083
说谎
说谎 2021-02-03 16:58

Graphql is great and I\'ve started using it in my app. I have a page that displays summary information and I need graphql to return aggregate counts? Can this be done?

5条回答
  •  隐瞒了意图╮
    2021-02-03 17:59

    ... need graphql to return aggregate counts? Can this be done?

    Yes, it can be done.

    Does GraphQL does it automatically for you? No, because it does not know / care about where you get your data source.

    How? GraphQL does not dictate how you get / mutate the data that the user has queried. It's up to your implementation to get the requested aggregated data. You could get aggregated data directly from your MongoDB and serve it back, or you get all the data you need from your data source and do the aggregation yourself.

提交回复
热议问题