Skip to content

Commit ae030c2

Browse files
authored
Merge pull request #2686 from buildkite/SUP-1881
Add examples of GraphQL multiple mutations with single queries
2 parents c56a58e + 531025e commit ae030c2

File tree

2 files changed

+108
-8
lines changed

2 files changed

+108
-8
lines changed

pages/apis/graphql/cookbooks/pipelines.md

Lines changed: 107 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ query RecentPipelineSlugs {
7777
}
7878
```
7979

80+
## Get a pipeline's ID
81+
82+
Get a pipeline's ID which can be used in other queries.
83+
84+
```graphql
85+
query {
86+
pipeline(slug:"organization-slug/pipeline-slug") {
87+
id
88+
}
89+
}
90+
```
91+
8092
## Get a pipeline's UUID
8193

8294
Get a pipeline's UUID by searching for it in the API. Search term can match a pipeline slug.
@@ -148,22 +160,36 @@ query AllPipelineMetrics {
148160

149161
## Delete a pipeline
150162

151-
First, get the ID of the pipeline you want to delete:
163+
First, [get the ID of the pipeline](#get-a-pipelines-id) you want to delete.
164+
Then, use the ID to delete the pipeline:
152165

153166
```graphql
154-
query {
155-
pipeline(slug:"organization-slug/pipeline-slug") {
156-
id
167+
mutation PipelineDelete {
168+
pipelineDelete(input: {
169+
id: "pipeline-id"
170+
})
171+
{
172+
deletedPipelineID
157173
}
158174
}
159175
```
160176

161-
Then, use the ID to delete the pipeline:
177+
### Delete multiple pipelines
178+
179+
First, [get the IDs of the pipelines](#get-a-pipelines-id) you want to delete.
180+
Then, use the IDs to delete multiple pipelines:
162181

163182
```graphql
164-
mutation PipelineDelete {
165-
pipelineDelete(input: {
166-
id: "pipeline-id"
183+
mutation PipelinesDelete {
184+
pipeline1: pipelineDelete(input: {
185+
id: "pipeline1-id"
186+
})
187+
{
188+
deletedPipelineID
189+
}
190+
191+
pipeline2: pipelineDelete(input: {
192+
id: "pipeline2-id"
167193
})
168194
{
169195
deletedPipelineID
@@ -188,3 +214,76 @@ mutation UpdateSchedule {
188214
}
189215
}
190216
```
217+
218+
## Archive a pipeline
219+
220+
First, [get the ID of the pipeline](#get-a-pipelines-id) you want to archive.
221+
Then, use the ID to archive the pipeline:
222+
223+
```graphql
224+
mutation PipelineArchive {
225+
pipelineArchive(input: {
226+
id: "pipeline-id"
227+
})
228+
{
229+
pipeline {
230+
id
231+
name
232+
}
233+
}
234+
}
235+
```
236+
237+
### Archive multiple pipelines
238+
239+
First, [get the IDs of the pipelines](#get-a-pipelines-id) you want to archive.
240+
Then, use the IDs to archive the pipelines:
241+
242+
```graphql
243+
mutation PipelinesArchive {
244+
pipeline1: pipelineArchive(input: {
245+
id: "pipeline1-id"
246+
})
247+
{
248+
pipeline {
249+
id
250+
name
251+
}
252+
}
253+
254+
pipeline2: pipelineArchive(input: {
255+
id: "pipeline2-id"
256+
})
257+
{
258+
pipeline {
259+
id
260+
name
261+
}
262+
}
263+
}
264+
```
265+
266+
## Unarchive a pipeline
267+
268+
First, [get the ID of the pipeline](#get-a-pipelines-id) you want to unarchive.
269+
Then, use the ID to unarchive the pipeline:
270+
271+
```graphql
272+
mutation PipelineUnarchive {
273+
pipelineUnarchive(input: {
274+
id: "pipeline-id"
275+
})
276+
{
277+
pipeline {
278+
id
279+
name
280+
}
281+
}
282+
}
283+
```
284+
285+
### Unarchive multiple pipelines
286+
287+
The process for unarchiving multiple pipelines is similar to that for [archiving multiple pipelines](#archive-a-pipeline-archive-multiple-pipelines).
288+
289+
However, use the field `pipelineUnrchive` (in `pipeline1: pipelineUnarchive(input: { ... })`, etc.) instead of `pipelineArchive`.

vale/styles/vocab.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ tooltip
207207
udp
208208
unarchive
209209
unarchived
210+
unarchiving
210211
unblocker
211212
unbuildable
212213
unclustered

0 commit comments

Comments
 (0)