Can't access the contributors of a repository

schema-request

#1

I’m trying to access the contributors of a repository and obtain their permission status on that repository. I can’t seem to find a way to do this simply with the GraphQL API. Am I missing something?

The data that I would like to have exposed:

A list collaborators as Users with their respective permission level.

Related existing REST API resource, if applicable:

A description of how you intend on using the data:

I’m currently using this data to check whether users found in an OWNERS file-like format are contributors, and whether they need to be granted read privilege or can be assigned as reviewers right away.


Contributors of a repository
#2

Hi @tobie,

I don’t believe that there’s currently a way to access repository contributors from the GraphQL API.

If you’d like, you can turn this topic into a “schema request”. Please just tag this topic with schema-request and provide:

  • The data that you would like to have exposed.
  • A link to the existing REST API resource, if applicable.
  • A description of how you intend on using the data.

#3

Done. (Edited the initial post).


#4

Thanks @tobie, I’ve added an internal issue to track this schema request. I’ll update you here when we have something to update.


#5

I’m quite interested in this as well. I need to be able to determine if a review left by a user “counts” toward the branch protection requirement. Only users that have write access can meet branch protection requirement of a passing review.


#6

+1 I would love this


#7

Hey @github-staff , any updates?


#8

We’ve just shipped support for a RepositoryCollaboratorConnection on Repository. You can now use it in your queries. Here is an example:

query {
  repository(owner: "peek", name: "peek") {
    id
    name
					
    collaborators(first: 10, affiliation: ALL) {
      edges {
        permission
        node {
          id
          login
          name
        }
      }
    }
  }
  
  rateLimit {
    cost
  }
}

Note: You must have push access to the repository before you can view the collaborators, otherwise it will return a forbidden error.

Thank you for your patience and for opening this thread @tobie!


Contributions by contributors in a repository
#9

Sweet! Thanks.


#11

As far as I now understood there is still not a way get the contributors of a repo with GraphQL?
Because for the collaborators you need to have push access.

For the v3 call there is no such “limitation”: https://api.github.com/repos/peek/peek/contributors

"errors": [
  {
    "message": "Must have push access to view repository collaborators.",
    "type": "FORBIDDEN",
    "path": [
      "repository",
      "collaborators"
    ],
    "locations": [
      {
        "line": 4,
        "column": 5
      }
    ]
  }
]

Also found maybe also my answer already here


#12

Hi @CodeBrauer! The collaborators connection does mirror the collaborators REST API in that both require push access to the repository.

$ curl -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/peek/peek/collaborators
{
  "message": "Must have push access to view repository collaborators.",
  "documentation_url": "https://developer.github.com/v3/repos/collaborators/#list-collaborators"
}

We are working on exposing contributors in GraphQL without needing push access, similar to the contributors endpoint in the REST API. We will follow up when there is progress.


#13

Hi, well ok - But for the moment I need the contributors in GraphQL, also for repos that I don’t have push access. So I have to take a workaround with a combination of the REST API and GraphQL.