Count with GraphQL
The count aggregation currently has some issues and this feature is also not available for Bookshelf (SQL databases).
With this guide we will code our own count query.
Here is the GraphQL documentation which we will use to achieve our goal.
Make sure you have a Content Type with some entries.
To be able to add a new custom query (or mutation), we will have to create a file in your Restaurant API.
Path — ./api/restaurant/config/schema.graphql.js
It needs a JSON object as params, so we will add a options in the GraphQL query.
Path — ./api/restaurant/config/schema.graphql.js
And tada, you can now request the of your Content Type.
- Count all restaurants