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

pullRequestListings.graphql

132 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 author {
41 login
42 }
43 }
44 }
45 additions @include(if: $stats)
46 deletions @include(if: $stats)
47 createdAt
48 updatedAt
49 mergedAt
50 repository {
51 nameWithOwner
52 }
53 reviewRequests(first: 20) {
54 nodes {
55 requestedReviewer {
56 ... on User {
57 login
58 }
59 ... on Team {
60 slug
61 }
62 }
63 }
64 }
65 labels(first: 20) {
66 nodes {
67 name
68 color
69 }
70 }
71 # GitHub's rollup for the head commit, one enum, rather than the whole check list: measured at a
72 # hundred rows, 0.8s -> 3.0s and 15 KB, against 425 KB for the same verdict as a check array.
73 commits(last: 1) {
74 nodes {
75 commit {
76 statusCheckRollup {
77 state
78 }
79 }
80 }
81 }
83​
84# Every repository of a host in one read, which is what makes a listing one request rather than
85# one per repository. `$first` is at most 100: `search` refuses anything larger with
86# EXCESSIVE_PAGINATION.
87query PullRequestSearch(
88 $q: String!
89 $first: Int!
90 $after: String
91 $stacks: Boolean!
92 $stats: Boolean!
93) {
94 search(query: $q, type: ISSUE, first: $first, after: $after) {
95 pageInfo {
96 hasNextPage
97 endCursor
98 }
99 nodes {
100 ...PullRequestRow
101 }
102 }
104​
105# A repository's pull requests without search, newest created first: the order `gh pr list` lists
106# in when it does not search, for a repository GitHub's search index does not cover.
107query PullRequestList(
108 $owner: String!
109 $name: String!
110 $states: [PullRequestState!]
111 $first: Int!
112 $after: String
113 $stacks: Boolean!
114 $stats: Boolean!
115) {
116 repository(owner: $owner, name: $name) {
117 pullRequests(
118 first: $first
119 after: $after
120 states: $states
121 orderBy: { field: CREATED_AT, direction: DESC }
122 ) {
123 pageInfo {
124 hasNextPage
125 endCursor
126 }
127 nodes {
128 ...PullRequestRow
129 }
130 }
131 }