How to fetch a user's permission level using GitHub App and GraphQL? #24513
-
I’m trying to fetch a user’s permission level using GitHub App and GraphQL. However, there seems to be only viewerPermission in the attributes of the repository. This value is always null in GitHub App. Can I write queries that add permissions for the specific user in a repository list? |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments
-
Hey there @wata727, help’s arrived! If you want, GitHub provides an API endpoint for adding different users as collaborators on a repository: https://developer.github.com/v3/repos/collaborators/#add-user-as-a-collaborator. Is this what you’re looking for? 🙂 |
Beta Was this translation helpful? Give feedback.
-
Hello @timrossback, Thanks for your reply! Unfortunately, that is not the API I want… I would like to list repositories including a user’s permission like the following:
The above response can be obtained by the following query:
However, viewPermission is always null in GitHub App like the following:
I want to avoid this and know how to fetch permission for a specific user. GitHub API v3 provides permission level API but this API requires to call it for each repository. This is very expensive… |
Beta Was this translation helpful? Give feedback.
-
Hey @wata727, I get what you mean! I’m probably not the best person to talk to about this since I don’t actively develop anything that integrates with GitHub. You might find that Stack Overflow might be able to help, though. Otherwise, you can always try asking the wonderful folks over at GitHub support 🙂 |
Beta Was this translation helpful? Give feedback.
-
The field you want is on the *edge* of collaborators. See this object’s |
Beta Was this translation helpful? Give feedback.
-
It will remain null for anyone other than the owner |
Beta Was this translation helpful? Give feedback.
-
Would be great to have a way to query the permission type given some user and the repository. |
Beta Was this translation helpful? Give feedback.
-
This API does exist: https://api.github.com/repos/OWNER/REPO/collaborators/USERNAME/permission The response is the following:
|
Beta Was this translation helpful? Give feedback.
This API does exist:
https://api.github.com/repos/OWNER/REPO/collaborators/USERNAME/permission
The response is the following: