Total answered/unanswered discussions

Hi,

I’d like to get the total number of answered/unanswered discussions for a repository using the GraphQL API. There seems to be no efficient way of doing this as of now, since we are only allowed to fetch 100 discussions’ details at once. Please let me know if this is possible/if I am missing out on something. Thanks!

1 Like

Hi there @profgrammer :wave:

Appreciate you joining us here in the Community and for posing your question! I’m curious of a couple things here.

Are you willing to share the query you’re working with, currently?

The query will help, but I’m wondering if you’re using any kind of pagination. If not, this may be your solution:

https://graphql.org/learn/pagination/

While general cursor based pagination is great, I’m wondering about your first statement:

I’d like to get the total number of answered/unanswered discussions

…where it sounds like you’re querying for details and are retrieving a full list of returned individual Discussions, but you should be able to return a totalCount value within your query, if a single number is what you’re after.

So if it’s pagination to retrieve batches of results, or if it’s using totalCount to get the number, these should be your considerations.

If I’ve misunderstood, let us know!

@nethgato thanks for your reply.
In essence what I want to achieve is: to retrieve the number of discussions on repository x whose answerChosenAt timestamp is not null (basically how many discussions on this repository have been answered).

I haven’t formulated a query yet, because I am not sure whether it is possible to do in a single query.

While I can use pagination to fetch records in batches and figure out the count programmatically, it would cause a lot of queries to be executed for a repository which has, for example, 5000 discussions. Is there any way to achieve this?

Thanks again!