2

GitHub API v4 does not show the results for companies when user query is used. If I use repositoryOwner instead, it returns results for both users and companies. However, user query can return more detailed information such as biography, website, location etc. which is not included in repositoryOwner query.

Is there an alternative option covering all type of users?

Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
user1449456
  • 502
  • 1
  • 5
  • 19

1 Answers1

5

You can access the User or Organization interface in RepositoryOwner using respectively ... on User & ... on Organization :

{
  repositoryOwner(login: "google") {
    ... on User {
      avatarUrl
      bio
    }
    ... on Organization {
      name
      members {
        totalCount
      }
    }
  }
}

Try it in the explorer

If the result is an organization it will only returns the fields you specifed in ... on Organization block, if the result is a user it will return the fields specified in ... on User, in this case as google is an organization :

{
  "data": {
    "repositoryOwner": {
      "name": "Google",
      "members": {
        "totalCount": 1656
      }
    }
  }
}
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159