You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: internal/cmd/api/README.md
+13-5Lines changed: 13 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
# `spacectl api`
2
2
3
-
`spacectl api` lets you run ad-hoc read-only GraphQL queries against the Spacelift API using your existing authentication.
3
+
`spacectl api` lets you run ad-hoc GraphQL operations against the Spacelift API using your existing authentication.
4
4
5
-
Mutations are not supported. For write operations, use the dedicated `spacectl` subcommands or the [Spacelift Terraform Provider](https://github.com/spacelift-io/terraform-provider-spacelift).
5
+
The provided document is sent unchanged to the API, so queries and mutations are both supported.
6
6
7
7
## Usage
8
8
9
-
Basic queries (bare field selections are wrapped in `query { ... }` automatically):
9
+
Basic queries:
10
10
11
11
```bash
12
-
spacectl api 'stacks { id name state }'
13
-
spacectl api 'workerPools { id name workers { id } }'
12
+
spacectl api '{ stacks { id name state } }'
13
+
spacectl api '{ workerPools { id name workers { id } } }'
14
14
```
15
15
16
16
Full query syntax:
@@ -25,12 +25,20 @@ With variables:
25
25
spacectl api --variables '{"id":"my-stack"}''query($id: ID!) { stack(id: $id) { id name } }'
26
26
```
27
27
28
+
Mutations:
29
+
30
+
```bash
31
+
spacectl api 'mutation { stackDelete(id: "my-stack") { id } }'
32
+
spacectl api 'mutation DeleteStack($id: ID!) { stackDelete(id: $id) { id } }' --variables '{"id":"my-stack"}'
33
+
```
34
+
28
35
From a file or stdin:
29
36
30
37
```bash
31
38
spacectl api < query.graphql
32
39
spacectl api --variables '{"id":"my-stack"}'< query.graphql
Description: "Pass a read-only GraphQL query as a positional argument, or pipe via stdin.\nBare field selections are wrapped as query { ... } automatically.\nMutations and subscriptions are not supported. Read more: https://github.com/spacelift-io/spacectl/tree/main/internal/cmd/api/README.md",
48
-
ArgsUsage: "[query]",
47
+
Description: "Pass a GraphQL document as a positional argument, or pipe via stdin.\nThe provided document is sent unchanged to the Spacelift GraphQL API. Read more: https://github.com/spacelift-io/spacectl/tree/main/internal/cmd/api/README.md",
0 commit comments