# get your own login
query {
viewer {
login
}
}
List the organizations for a user:
query MyOrgs {
viewer {
organizations(first: 100) {
nodes {
login
}
}
}
}
Get the Teams for an organization:
# get teams for an organization
query {
organization(login: "name_of_organization") {
teams(first: 10) {
edges {
node {
name
repositories(first: 10) {
edges {
node {
name
}
}
}
}
}
}
}
}
List a users's teams within an organization:
{
organization(login: "my-org") {
teams(first: 100, userLogins: ["johndoe"]) {
totalCount
edges {
node {
name
description
}
}
}
}
}
Global (all repos) List of PRs assigned to you (or your teams)
{
search(query: "type:pr state:open review-requested:StevenACoffman", type: ISSUE, first: 100) {
issueCount
pageInfo {
endCursor
startCursor
}
edges {
node {
... on PullRequest {
url
}
}
}
}
}
The query for a team's requested reviews is: team-review-requested:ORG/TEAMNAME
where ORG
should be replaced with the organization, and TEAMNAME
replaced with the team name.
To find the members of a team:
{
organization(login: "khan") {
teams(first: 100, query: "districts") {
totalCount
edges {
node {
members {
edges {
node {
name
login
}
}
}
name
description
}
}
}
}
}
To find open pull requests authored by a person (for instance, a member of team):
{
search(query: "is:open is:pr is:private archived:false author:StevenACoffman", type: ISSUE, first: 100) {
issueCount
edges {
node {
... on PullRequest {
number
title
repository {
nameWithOwner
}
createdAt
mergedAt
url
changedFiles
additions
deletions
}
}
}
}
}
We use the URL of our pull request to find the pull requests's resource ID using query variables like {"url": "https://github.com/Khan/webapp/pull/1100"}
:
query findPRNodeId($url: URI!) { resource(url: $url) { ... on PullRequest { id } } }
Then we can comment on a pull request using the resourceID from above in this mutation:
mutation addComment($subjectId: ID!, $clientMutationId: String, $body: String!) {
addComment(input: {subjectId: $subjectId, clientMutationId: $clientMutationId, body: $body}) {
subject {
id
}
}
}
With the query variables in that above mutation being:
{
"clientMutationId": "Apollo Schema Validation",
"subjectId": "MDExOlB1bGxSZXF1ZXN0NzIxNjQ3OTg4",
"body": "This is a test comment"
}
Look up pull request by ref: https://gist.github.com/mccutchen/9a0530a440470b4dee57c53284a18b52 Look up pull requests in various ways: https://gist.github.com/MichaelCurrin/f8a7a11451ce4ec055d41000c915b595
Gists: https://gist.github.com/jamesluberda/d73376298e22e3fc4abbca590b97d5e0
Qualifier | Notes |
---|---|
review:none |
Returns pull requests that have not been reviewed |
review:required |
Returns pull requests that have not been reviewed but have a protected branch |
review:approved |
Returns approved pull requests |
review:changes_requested |
Returns pull requests that have requested changes |
reviewed-by:USERNAME |
Returns pull requests that have been reviewed by the specified user |
review-requested:USERNAME |
Now returns pull requests that have direct requests and team requests |
team-review-requested:TEAMNAME |
Returns pull requests with requests for the specified team |
You can go to https://github.com/search or https://github.com/pulls and make various queries for GitHub Pull requests. (edited)
You can search for open pull requests in private repos authored by multiple people (e.g. your team mates) by just adding multiple author:<whatshisface>
like this:
is:open is:pr is:private archived:false author:StevenACoffman author:drewkiimon author:kphilipkhan author:jeffkhan
You can look for PRs where reviews are requested for a particular team by using: team-review-requested:Khan/districts
as in:
is:open is:pr is:private archived:false team-review-requested:Khan/districts
You can look for PRs where a team was mentioned by using: team:Khan/TEAMNAME
as in:
is:open is:pr is:private archived:false team:Khan/districts
You can look for PRs where you were mentioned by using your github userid: mentions:StevenACoffman
as in:
is:open is:pr is:private archived:false mentions:StevenACoffman
You can look for PRs where your review was requested by using: review-requested:StevenACoffman
as in:
is:open is:pr is:private archived:false review-requested:StevenACoffman
You can make a GraphQL batch query for these like this:
query MyBatch {
merequested: search(query: "is:open is:pr is:private archived:false review-requested:StevenACoffman", type: ISSUE, first: 100) {
issueCount
edges {
node {
... on PullRequest {
number
title
repository {
nameWithOwner
}
createdAt
mergedAt
url
changedFiles
additions
deletions
}
}
}
}
mementioned: search(query: "is:open is:pr is:private archived:false mentions:StevenACoffman", type: ISSUE, first: 100) {
issueCount
edges {
node {
... on PullRequest {
number
title
repository {
nameWithOwner
}
createdAt
mergedAt
url
changedFiles
additions
deletions
}
}
}
}
teammates: search(query: "is:open is:pr is:private archived:false author:StevenACoffman author:drewkiimon author:kphilipkhan author:jeffkhan", type: ISSUE, first: 100) {
issueCount
edges {
node {
... on PullRequest {
number
title
repository {
nameWithOwner
}
createdAt
mergedAt
url
changedFiles
additions
deletions
}
}
}
}
teammentions: search(query: "is:open is:pr is:private archived:false team:Khan/districts", type: ISSUE, first: 100) {
issueCount
edges {
node {
... on PullRequest {
number
title
repository {
nameWithOwner
}
createdAt
mergedAt
url
changedFiles
additions
deletions
}
}
}
}
teamrequested: search(query: "is:open is:pr is:private archived:false team-review-requested:Khan/districts", type: ISSUE, first: 100) {
issueCount
edges {
node {
... on PullRequest {
number
title
repository {
nameWithOwner
}
createdAt
mergedAt
url
changedFiles
additions
deletions
}
}
}
}
}
To find out more information about a particular pull request:
query {
repository(owner: "nodejs", name: "node") {
pullRequest(number: 2) {
id
number
title
author {
login
}
}
}
}