GraphQL API: How to fetch all repositories that the current user has access to #24860
-
I’m trying to find a GraphQL equivalent of the > List repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access. I’ve tried following query but that only returns repositories under my account, and not the other repositories I have access to (organizational repos - both public and private):
EDIT: I’ve also tried to use affiliations but without success - still returns only repositories directly under my “jumarko” account:
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
try repositoriesContributedTo instead of repositories |
Beta Was this translation helpful? Give feedback.
-
Thanks for the suggestion but that doesn’t sound right. I want to get a list of all repositories I have access to, not only the ones I’ve contributed too. As mentioned before, I want an equivalent of _user/_repos endpoint of v3 API, which for more returns 2300+ repositories while the “equivalent” GraphQL API query (see my previous post) returns only 207 repositories. repositoriesContributedTo I contributed to returns only 85 repos (with includeUserRepositories set to true). |
Beta Was this translation helpful? Give feedback.
-
Hey @jumarko, Thanks for being here, have you tried?
|
Beta Was this translation helpful? Give feedback.
-
@andreagriffiths11 thanks for the suggestion but that does the same thing as my first query. |
Beta Was this translation helpful? Give feedback.
-
Seems to be already reported and awaiting for GitHub feedback: https://github.community/t5/GitHub-API-Development-and/Grapql-viewer-repositories-gets-only-repositories-where-the-user/m-p/14318?collapse_discussion=true&page=2&q=graphql%20user%20repositories&search_type=thread |
Beta Was this translation helpful? Give feedback.
-
@jumarko Did you find a way to get all the repos. I really don’t wanna use v3 for this. |
Beta Was this translation helpful? Give feedback.
-
@krasimir No, I use V3 rest api to load list of repos. |
Beta Was this translation helpful? Give feedback.
-
Ok, fair enough. I’ll do the same for the time being. |
Beta Was this translation helpful? Give feedback.
-
I found the solution! Add the following parameters to your Not sure why this is necessary to retrieve private organisation repos and not public organisation repos, but nevertheless it works. |
Beta Was this translation helpful? Give feedback.
I found the solution!
Add the following parameters to your
repositories
query:affiliations:[OWNER, ORGANIZATION_MEMBER, COLLABORATOR], ownerAffiliations:[OWNER, ORGANIZATION_MEMBER, COLLABORATOR]
Not sure why this is necessary to retrieve private organisation repos and not public organisation repos, but nevertheless it works.