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

pullRequestListings.graphql

133 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 }
71 }
72 # GitHub's rollup for the head commit, one enum, rather than the whole check list: measured at a
73 # hundred rows, 0.8s -> 3.0s and 15 KB, against 425 KB for the same verdict as a check array.
74 commits(last: 1) {
75 nodes {
76 commit {
77 statusCheckRollup {
78 state
79 }
80 }
81 }
82 }
84​
85# Every repository of a host in one read, which is what makes a listing one request rather than
86# one per repository. `$first` is at most 100: `search` refuses anything larger with
87# EXCESSIVE_PAGINATION.
88query PullRequestSearch(
89 $q: String!
90 $first: Int!
91 $after: String
92 $stacks: Boolean!
93 $stats: Boolean!
94) {
95 search(query: $q, type: ISSUE, first: $first, after: $after) {
96 pageInfo {
97 hasNextPage
98 endCursor
99 }
100 nodes {
101 ...PullRequestRow
102 }
103 }
105​
106# A repository's pull requests without search, newest created first: the order `gh pr list` lists
107# in when it does not search, for a repository GitHub's search index does not cover.
108query PullRequestList(
109 $owner: String!
110 $name: String!
111 $states: [PullRequestState!]
112 $first: Int!
113 $after: String
114 $stacks: Boolean!
115 $stats: Boolean!
116) {
117 repository(owner: $owner, name: $name) {
118 pullRequests(
119 first: $first
120 after: $after
121 states: $states
122 orderBy: { field: CREATED_AT, direction: DESC }
123 ) {
124 pageInfo {
125 hasNextPage
126 endCursor
127 }
128 nodes {
129 ...PullRequestRow
130 }
131 }
132 }