Get contributor count with the graphql api

Hi,

Is it possible to get a total contributor count from a repository, as is displayed at the top of the repository, with the graphql api?

I was able to retrieve all commits and get the author, but I can’t compute a count through that endpoint or get a total count through the repository object.

4 Likes

Hi @acrobat,

Thanks for being here! As of now, you might get the total count of commits ie:

query {
  repository(owner:"rails", name:"rails") {
    object(expression:"master") {
      ... on Commit {
        history {
          totalCount
        }
      }
    }
  }
}

A schema has been requested to get the total contributor numbers and is a work in progress, I’ll do some more digging and post any other updates here.

5 Likes

Hi @andreagriffiths11, That’s indeed the graphql query I use to get the commit count. Thanks for requesting the schema change, I will wait for an update when this is available!

2 Likes

@andreagriffiths11 any update on status of a contributor count value in graphql?

1 Like

Battling the same need myself.  Hoping to see a commit/history/totalContributors or something like that.

1 Like

Do you have any sample code to display?

@andreagriffiths11 I just found out that there is an REST api endpoint to get the contributor information (and by fetching all results and counting them also the contributor count)

Is this info also available in a graphql query? As it would be much more efficient to query!