Reputation: 642
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?
Upvotes: 3
Views: 817
Reputation: 45483
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
}
}
}
}
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
}
}
}
}
Upvotes: 6