Pull requests for an org


#1

If I go to the GitHub UI, click ‘pull requests’, then update the filter to be ‘is:open is:pr user:ourorg archived:false’ I get a list of open PRs within our org.

How do/can i do the equivalent with a graphql query?

Thanks

Andy


#2

You’re probably looking for something like this:

query {
	repository(owner:"eslint",name:"doctrine") {
		pullRequests(first: 5, states:OPEN) {
			nodes {
				number
				state
			}
		}
	}
}

Which should give you a list of 5 open PRs for the doctrine repo owned by eslint. You can adjust the parameters to fit your needs.


#3

That’s only for a single repo - the search does all repos under the org

Any way to do that?


#4

You will need to adjust the parameters or paginate the results, but this should get you started:

query {
	organization(login: "ourorg") {
		repositories(first:5) {
			nodes {
				pullRequests(first:5, states:OPEN) {
					nodes {
						title
						number
					}
				}
			}
		}
	}
}

#5

excellent - thank you