Skip to content

Commit 379fd43

Browse files
committed
graphql api docs
1 parent 22033fa commit 379fd43

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

docs/astro.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export default defineConfig({
7373
items: [
7474
{ label: 'CLI Commands', slug: 'reference/cli' },
7575
{ label: 'REST API', slug: 'reference/rest-api' },
76+
{ label: 'GraphQL API', slug: 'reference/graphql-api' },
7677
{ label: 'Webhooks', slug: 'reference/webhooks' },
7778
],
7879
},
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
---
2+
title: GraphQL API
3+
description: Reference for the read-only stack fields and objects on the GraphQL PullRequest type.
4+
---
5+
6+
The GraphQL API exposes a pull request's stack membership through two read-only fields on the `PullRequest` type, backed by a small set of stack objects. These fields are **read-only** — there are no stack mutations via GraphQL. To create or modify stacks use the [REST API](/gh-stack/reference/rest-api/).
7+
8+
## Fields on `PullRequest`
9+
10+
| Field | Type | Description |
11+
|-------|------|-------------|
12+
| `stack` | `PullRequestStack` | The stack this pull request belongs to, or `null` if it is not part of a stack. |
13+
| `stackEntry` | `PullRequestStackEntry` | This pull request's entry within its stack (including its position), or `null` if it is not part of a stack. |
14+
15+
## Objects
16+
17+
### `PullRequestStack`
18+
19+
A stack of pull requests.
20+
21+
| Field | Type | Description |
22+
|-------|------|-------------|
23+
| `id` | `ID!` | The Node ID of the `PullRequestStack` object. |
24+
| `number` | `Int!` | A number uniquely identifying the stack within its repository. |
25+
| `size` | `Int!` | The total number of pull requests in the stack. |
26+
| `baseRefName` | `String!` | The branch that the stack's pull requests target. |
27+
| `entries` | `PullRequestStackEntryConnection!` | The entries in the stack. |
28+
29+
### `PullRequestStackEntry`
30+
31+
A member of a `PullRequestStack`.
32+
33+
| Field | Type | Description |
34+
|-------|------|-------------|
35+
| `id` | `ID!` | The Node ID of the `PullRequestStackEntry` object. |
36+
| `position` | `Int!` | This entry's position in the stack, where `1` is the closest to the base branch, `2` is stacked on top of `1`, and so on. |
37+
| `pullRequest` | `PullRequest` | The pull request that occupies this position in the stack. |
38+
| `stack` | `PullRequestStack` | The stack that this entry is a part of. |
39+
40+
### `PullRequestStackEntryConnection`
41+
42+
A paginated connection of stack entries. Follows the standard [GraphQL connection pattern](https://docs.github.com/en/graphql/guides/introduction-to-graphql#connection).
43+
44+
| Field | Type | Description |
45+
|-------|------|-------------|
46+
| `edges` | `[PullRequestStackEntryEdge]` | A list of edges. |
47+
| `nodes` | `[PullRequestStackEntry]` | A list of the entries. |
48+
| `pageInfo` | `PageInfo!` | Information to aid in pagination. |
49+
| `totalCount` | `Int!` | The total number of entries in the connection. |
50+
51+
### `PullRequestStackEntryEdge`
52+
53+
An edge in a `PullRequestStackEntryConnection`.
54+
55+
| Field | Type | Description |
56+
|-------|------|-------------|
57+
| `cursor` | `String!` | A cursor for use in pagination. |
58+
| `node` | `PullRequestStackEntry` | The item at the end of the edge. |
59+
60+
## Example
61+
62+
Read a pull request's stack, its position, and every pull request in the stack:
63+
64+
```graphql
65+
{
66+
repository(owner: "OWNER", name: "REPO") {
67+
pullRequest(number: 42) {
68+
number
69+
baseRefName
70+
stackEntry {
71+
position
72+
}
73+
stack {
74+
number
75+
size
76+
baseRefName
77+
entries(first: 20) {
78+
totalCount
79+
nodes {
80+
position
81+
pullRequest {
82+
number
83+
title
84+
state
85+
}
86+
}
87+
}
88+
}
89+
}
90+
}
91+
}
92+
```
93+
94+
The pull request's own `baseRefName` is the branch it directly targets (the PR below it in the stack), while `stack.baseRefName` is the branch the entire stack ultimately targets. These differ for every PR in the stack except the bottom one.

0 commit comments

Comments
 (0)