Using GitHub's GraphQL API (v4), how do I query for the top contributors of a given repository? I have a list of repositories and I'd like to display some relevant data for each repository–namely, the top 5 contributors (based on commits) for each repository in the list.
Here is my current query:
{
organization(login: "the-road-to-learn-react") {
id
repositories(first: 20) {
edges {
node {
collaborators(affiliation: ALL) {
edges {
node {
name
}
}
}
}
}
}
}
}
I'm running into the error: "Must have push access to view repository collaborators". My thought is to get all of the collaborators for each repository, then query each of those users for the number of contributions made to the repository. How can this be done? Is there a way to do this without querying for repository collaborators?
In order to access the repository collaborators list through the API you have to be one of the collaborators
in the project.
You can read more about Permission levels for a user account repository.
And even if you are one of the collaborators, the organization might have not have OAuth App access
to some of the repositories.
You can read more about Restricting access to your organization's data.
So I believe that query can't be done unless the above requirements are met.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With