Getting an Organization from a Repository?


#1

I suspect this isn’t feasible but I don’t know the full depth of working with GraphQL yet. Working from pull requests I’m involved in, I want to see the organization of the repository of the pull request. Specifically I want to find users that may not be directly involved with the pull request (yet) via teams that have ‘ownership’ of the repository. However, I can only get a RepositoryOwner interface from the Repository.

Is it possible to read this like an Organization? I know Users and Organizations are similar enough to warrant the abstraction, so I’m only hoping there’s a way to do this.

Alternatively, if members of a team that owns the repository are automatically considered contributors or involved with it somehow, then I may not have a need to do this.


List repositories filtered by owner and repo name
#2

It is possible to spread the RepositoryOwner interface to an Organization object via a fragment:

{
  repository(owner:"jquery" name:"jquery") {
    pullRequests(first:10) {
      edges {
        node {
          headRepository {
            owner {
              ... on Organization {
                teams {
                  edges {
                    node {
                      description
                    }
                  }
                }
              }
            }
          }
        }
      }
    } 
  }
}

However, as you noted in your other post, it isn’t possible to list permissions for teams currently, so I doubt this helps you much.


#3

That’s actually incredibly useful. I won’t need another query to relate these teams to the pull request. If I can restructure my query a bit, I may be able to reduce it to one query entirely (and not necessarily need to view team’s repositories).

Edit: I vaguely got the notion that these were teams for the pull request and I know that’s not right… I still can’t relate teams and pull requests without using the REST api. Still, it lets me build a more robust query.


#4

Hi @alecxvs,

It looks like @karagenit had a great suggestion above but as they pointed out we still don’t support team permissions or filtering. For that, I’d suggest creating a schema request and we can prioritize working on that for you.

Here’s a different take on the query that might be a suitable workaround until something is in place:

query {
  user(login:"alecxvs") {
    pullRequests(last:30) {
      edges {
        node {
          title
          repository {
            owner {
              ... on Organization {
                name
              }
            }
          	mentionableUsers(last:30) {
              edges {
                node {
                  name
                }
              }
            }
          }
        }
      }
    }
  }
}

That should get you the organization name and a list of “mentionable users” which is organization and repository-aware.