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
          }
    }
}

1 Like

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!

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

1 Like

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

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 :slight_smile:
{
repository(name: “a_repo_name”, owner:“org_or_individual”) {
pullRequests(first: 1) {
pageInfo {
endCursor
hasNextPage
}
nodes {
id
url
body
}
}
}
}

1 Like