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

pullRequestListings.graphql

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