# GraphQL CLI command reference

**CLI output**

```sh
npx sanity graphql --help
```

## Commands

### `deploy`

**CLI output**

```sh
USAGE
  $ sanity graphql deploy [-d <name>] [--api <value>] [--dry-run] [--force] [--generation <value>] [--non-null-document-fields] [--playground] [--tag <value>] [--with-union-cache]

FLAGS
  -d, --dataset=<name>            Deploy API for the given dataset
      --api=<value>               Only deploy API with this ID (can be specified multiple times)
      --dry-run                   Validate defined GraphQL APIs, check for breaking changes, skip deploy
      --force                     Deploy API without confirming breaking changes
      --generation=<value>        API generation to deploy (defaults to "gen3")
      --non-null-document-fields  Use non-null document fields (_id, _type etc)
      --playground                Enable GraphQL playground for easier debugging
      --tag=<value>               Deploy API(s) to given tag (defaults to "default")
      --with-union-cache          Cache union types (faster for schemas with many self-references)

DESCRIPTION
  Deploy a GraphQL API from the current Sanity schema

EXAMPLES
  Deploy all defined GraphQL APIs

    $ sanity graphql deploy

  Validate defined GraphQL APIs, check for breaking changes, skip deploy

    $ sanity graphql deploy --dry-run

  Deploy only the GraphQL APIs with the IDs "staging" and "ios"

    $ sanity graphql deploy --api staging --api ios

  Deploy all defined GraphQL APIs, overriding any playground setting

    $ sanity graphql deploy --playground
```

### `list`

**CLI output**

```sh
USAGE
  $ sanity graphql list [-p <id>]

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to list GraphQL endpoints for (overrides CLI configuration)

DESCRIPTION
  List deployed GraphQL endpoints for the project

EXAMPLES
  List GraphQL endpoints for the project

    $ sanity graphql list

  List GraphQL endpoints for a specific project

    $ sanity graphql list --project-id abc123
```

### `undeploy`

**CLI output**

```sh
USAGE
  $ sanity graphql undeploy [-d <name>] [-p <id>] [--api <value>] [--force] [--tag <value>]

FLAGS
      --api=<value>  Undeploy API with this ID
      --force        Skip confirmation prompt
      --tag=<value>  Tag to undeploy GraphQL API from

OVERRIDE FLAGS
  -d, --dataset=<name>   Dataset to undeploy GraphQL API from (overrides CLI configuration)
  -p, --project-id=<id>  Project ID to undeploy GraphQL API from (overrides CLI configuration)

DESCRIPTION
  Remove a deployed GraphQL API

EXAMPLES
  Undeploy GraphQL API for current project and dataset

    $ sanity graphql undeploy

  Undeploy API with ID "ios"

    $ sanity graphql undeploy --api ios

  Undeploy GraphQL API for staging dataset

    $ sanity graphql undeploy --dataset staging

  Undeploy GraphQL API for staging dataset with "next" tag

    $ sanity graphql undeploy --dataset staging --tag next

  Undeploy GraphQL API without confirmation prompt

    $ sanity graphql undeploy --force

  Undeploy GraphQL API for a specific project and dataset

    $ sanity graphql undeploy --project-id abc123 --dataset production
```



## Related changelog entries

Entries are listed newest first. Follow a link (or append `.md` to its URL for a plain-markdown response) when you need to know what changed, when, or why — for example, to summarize recent updates, explain behavior that differs from older documentation, or check whether a fix has shipped.

- [Renamed API, Theming improvements ++](https://www.sanity.io/docs/changelog/5784e03f-504d-4f74-a6be-443ad1fd96b6) — *v3.24.1* — January 11, 2024
- [Removing warning for new fields in GraphQL schemas](https://www.sanity.io/docs/changelog/8c51bef3-7b53-496e-a393-99ed6dc55ee6) — *v2.17.2* — August 31, 2021