Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 5

GraphQL API: Can't use 'Repository' to access organization repos

I'm running the query below having created a PAT with admin:org and repo permissions. However the query only seems to work if the name is a repo within my account (in this case, also the organisation owner) , and returns null for the organization repos. Does that behaviour make sense? If instead I use 'repositories' I'm ok but would have preferred to just go 'straight in'. Perhaps the issue is that repo names could be duplicated within different accounts, and that this is therefore the accepted behaviour.
{
    viewer {
           repository(name:"wont_accept_organization_repos") {
          id
          }
    }
}
 
4 Replies
Pilot Lvl 2
Message 2 of 5

Re: GraphQL API: Can't use 'Repository' to access organization repos

I tried using the Repository field myself and I think it only searches repositories that the viewer owns. But, the Repositories connection does give developers a ton of filter options, including viewing repositories that you collaborate on, are a member of the underlying organization, or own yourself.

 

Hope this helps!

 

Gavin R. Isgar - Freelance Software Developer
Copilot Lvl 2
Message 3 of 5

Re: GraphQL API: Can't use 'Repository' to access organization repos

Thanks Gavin. I'll dig around the filter options, that seems sensible.

Pilot Lvl 2
Message 4 of 5

Re: GraphQL API: Can't use 'Repository' to access organization repos

No problem! If you have any other questions regarding this topic, just reply once more and we'll see what we can do!

 

Gavin R. Isgar - Freelance Software Developer
Copilot Lvl 2
Message 5 of 5

Re: GraphQL API: Can't use 'Repository' to access organization repos

Actually...this seems to be what I need. With this and the PTA I was able to get at any org repo as well as private repos under my account. It seems this is not the same as viewer{ repository .. Clearly early days for me with the API :-)
{
repository(name: "a_repo_name", owner:"org_or_individual") {
pullRequests(first: 1) {
pageInfo {
endCursor
hasNextPage
}
nodes {
id
url
body
}
}
}
}