Is there a Count for GraphQL? I used the DQL one, but i need one for GraphQL as well?

Could someone help me please with this question? I have read that GraphQL doesn’t support Count, like the one in DQL?

How do you guys query the count of a type with GraphQL then? I only need the count of a type, it takes too long to query all the ids of the nodes and do a result.length in the front-end.

Use the aggregate queries. Something like:

query {
  aggregateMyType {
    count
  }
}

I think this was added in 20.07 if I remember correctly. So anything you read dated prior to July 2020 will not reflect that counts are now available.

2 Likes

Thanks, that works! Would be great if they added that to the documentation, couldn’t find anything in the GraphQL docs.

Appreciate your help!

https://dgraph.io/docs/graphql/queries/aggregate/