Skip to content
Source
Sign inSign up
Open History to see the last commit

pullRequestListings.graphql

134 lines3.0 KB

1# Listings: a search across one or more repositories, and a repository's own list for one GitHub's
2# search index does not cover. Both answer with the same row.
3​
4# One listing row. `first` on the inner connections is a bound rather than a page: a pull request
5# with more than twenty labels shows twenty, and one that has asked more than twenty people for a
6# review is already past what a row can say.
7#
8# `additions` and `deletions` are asked for only with `$stats`: measured over twelve repositories
9# at a hundred rows, a search answers in ~4.0s without them and ~7.1s with them, for two numbers at
10# the end of a row. The cross-repository search reads them afterwards, in `PullRequestStats`.
11# `stack` and `stackEntry` exist on github.com only (`$stacks`).
12fragment PullRequestRow on PullRequest {
13 stack @include(if: $stacks) {
14 number
15 size
16 baseRefName
17 }
18 stackEntry @include(if: $stacks) {
19 position
20 }
21 number
22 title
23 url
24 author {
25 login
26 avatarUrl
27 ... on User {
28 name
29 }
30 }
31 headRefName
32 baseRefName
33 state
34 isDraft
35 mergeable
36 reviewDecision
37 latestReviews(first: 20) {
38 nodes {
39 state
40 isMinimized
41 author {
42 login
43 }
44 }
45 }
46 additions @include(if: $stats)
47 deletions @include(if: $stats)
48 createdAt
49 updatedAt
50 mergedAt
51 repository {
52 nameWithOwner
53 }
54 reviewRequests(first: 20) {
55 nodes {
56 requestedReviewer {
57 ... on User {
58 login
59 }
60 ... on Team {
61 slug
62 }
63 }
64 }
65 }
66 labels(first: 20) {
67 nodes {
68 name
69 color
70 description
71 }
72 }
73 # GitHub's rollup for the head commit, one enum, rather than the whole check list: measured at a
74 # hundred rows, 0.8s -> 3.0s and 15 KB, against 425 KB for the same verdict as a check array.
75 commits(last: 1) {
76 nodes {
77 commit {
78 statusCheckRollup {
79 state
80 }
81 }
82 }
83 }
85​
86# Every repository of a host in one read, which is what makes a listing one request rather than
87# one per repository. `$first` is at most 100: `search` refuses anything larger with
88# EXCESSIVE_PAGINATION.
89query PullRequestSearch(
90 $q: String!
91 $first: Int!
92 $after: String
93 $stacks: Boolean!
94 $stats: Boolean!
95) {
96 search(query: $q, type: ISSUE, first: $first, after: $after) {
97 pageInfo {
98 hasNextPage
99 endCursor
100 }
101 nodes {
102 ...PullRequestRow
103 }
104 }
106​
107# A repository's pull requests without search, newest created first: the order `gh pr list` lists
108# in when it does not search, for a repository GitHub's search index does not cover.
109query PullRequestList(
110 $owner: String!
111 $name: String!
112 $states: [PullRequestState!]
113 $first: Int!
114 $after: String
115 $stacks: Boolean!
116 $stats: Boolean!
117) {
118 repository(owner: $owner, name: $name) {
119 pullRequests(
120 first: $first
121 after: $after
122 states: $states
123 orderBy: { field: CREATED_AT, direction: DESC }
124 ) {
125 pageInfo {
126 hasNextPage
127 endCursor
128 }
129 nodes {
130 ...PullRequestRow
131 }
132 }
133 }