Return GitHub Repositories where user is an administrator

schema-request

#1

Is there a way in GraphQL to return a list of repositories which a user has administrator rights over?

E.G Let’s say we have user JohnDoe.

JohnDoe has access to 7 GitHub Repositories.

  1. Repo1
  2. Repo2
  3. Repo3
  4. Repo4
  5. Repo5
  6. Repo6
  7. Repo7

Each repository has 3 teams one. One read, one write and one admin.

JohnDoe is part of all the read teams & write teams on all the above repositories. But is only an administrator on repository 6 & 7.

We are looking to form a query that would return the repo names: Repo6, Repo 7.

Now, with REST this takes up about 3,000 API calls because we have 4,000 + repositories and have to loop through them all. We are really hoping there is a good way to do this via GraphQL Query?

This is the best which I could find:

query ($user: String!) {
  user(login: $user) {
    email
    organizations(first: 10) {
      edges {
        node {
          id
          name
          teams(userLogins: [$user], first: 10) {
            edges {
              node {
                name
                repositories(first: 100, orderBy: {field: PERMISSION, direction: ASC}) {
                  edges {
                    permission
                    node {
                      name
                      viewerCanAdminister
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

There doesn’t seem to be a way to filter the repositories by the permissions a Team has on it. Any ideas?


#2

If this isn’t doable right now :slight_smile: Is there any chance we could add it as a feature :slight_smile: Like be able to filter by permissions :slight_smile:


#3

:wave: @NickLiffen ,

Unfortunately as you noticed it’s only possible to order, and not filter, by permissions. I’ve added this to our internal tracker and we’ll update this thread when we have some more information.


#4

Thanks :slight_smile: It would be great, our use can is just getting a list of repositories that a user has administer rights over within an organization :slight_smile: For sure we could filter this in code after the query, but it would be great if we could get granular within the query itself and be able to filer, thanks for your help :1st_place_medal: