Grapql viewer repositories gets only repositories where the user is collaborator #24861
-
I am trying to run this query with my account by it is only returning repositories which I am contributor:
|
Beta Was this translation helpful? Give feedback.
Replies: 12 comments
-
Hi @ajanoni, Thank you for being here! Could you try to enable “Organization access” when authorizing the GraphQL API Explorer? |
Beta Was this translation helpful? Give feedback.
-
I am using a personal access token with all grants enabled. |
Beta Was this translation helpful? Give feedback.
-
And when I use
Then it returns all organization repositories. So I guess it is not an access grant issue. |
Beta Was this translation helpful? Give feedback.
-
Hey @ajanoni, Thanks for the update! I think you might’ve stumbled on a bug here…I’ll report it to the API team, and will post an update here once I hear back. Thanks again! Andrea |
Beta Was this translation helpful? Give feedback.
-
@ajanoni do you have any news on this one. I’m also in a need to fetch all the repos associated with my account but I’m only getting the public repos. Similar request works just fine with the v3 API. |
Beta Was this translation helpful? Give feedback.
-
I can confirm that this is probably a bug because I do see private repos using graphql API with the same public token when I’m doing a search. For example:
shows public repos and private repos owned by |
Beta Was this translation helpful? Give feedback.
-
Still hitting this bug. Is the solution using the rest API for grabbing repos? |
Beta Was this translation helpful? Give feedback.
-
Hi @vachi! Hopefully, you found a workaround for this issue, but you may want to try combinations of the affiliations and ownerAffiliations arguments (possibly both!). I ran into this issue in GitHub Enterprise Server, and these were the query arguments that worked for me:
This started happening when ownerAffiliations was added to GitHub Enterprise Server 2.16 and to github.com. When I contacted Enterprise support to debug the new query behavior, this was their response: I believe the behaviour you’ve reported is as a result of a change that shipped in GitHub Enterprise 2.16 release series, where an ownerAffiliations parameter was added to the Repositories connection in our GraphQL API. Before this change, the affiliations field was overloaded to mean both the affiliations that the viewer had with the specified repositories, as well as the affiliations between the user that the connection was operating on. This caused a host of issues in various places, and we opted to separate them out to allow for more flexibility. In order to fix the above, you need to pass the relevant list of arguments to both connections, which should provide you all of the possible repositories. That is, for your query, pass both the ownerAffiliations: [ORGANIZATION_MEMBER] and affiliations: [ORGANIZATION_MEMBER] repository affiliation arguments.
|
Beta Was this translation helpful? Give feedback.
-
This doesn’t work for me. |
Beta Was this translation helpful? Give feedback.
-
Hi Andrea, has the team gotten back to you yet? This bug has existed for quite some time now and the only solution seems to be to go back to using the v3 API. |
Beta Was this translation helpful? Give feedback.
-
Ah but it lead me to the correct solution: |
Beta Was this translation helpful? Give feedback.
-
Never mind Andrea, I found the solution: need to set |
Beta Was this translation helpful? Give feedback.
Never mind Andrea, I found the solution: need to set
affiliations:[OWNER, ORGANIZATION_MEMBER, COLLABORATOR], ownerAffiliations:[OWNER, ORGANIZATION_MEMBER, COLLABORATOR]
. Not sure why this is necessary for private organisations and not public organisations, but at least I can get all the repos I have access to now!