Unlock seamless workflows and faster delivery with our latest releases - Join the deep dive

GraphQL

Deploy, delete and list GraphQL APIs for Sanity projects

Available commands

usage: sanity graphql [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>]

Commands:
   deploy    Deploy a GraphQL API from the current Sanity schema
   list      Lists all the GraphQL endpoints deployed for this project
   undeploy  Remove a deployed GraphQL API

See 'sanity help graphql <command>' for specific information on a subcommand.

Deploying/updating an API

usage: sanity graphql deploy

   Deploy a GraphQL API from the current Sanity schema

Options
  --dataset <dataset> Deploy API for the given dataset
  --tag <tag> Deploy API to given tag (defaults to 'default')
  --generation <generation> API generation to deploy (defaults to 'gen3')
  --non-null-document-fields Set document interface fields (_id, _type etc) as non-null
  --playground Deploy a GraphQL playground for easily testing queries (public)
  --no-playground Skip playground prompt (do not deploy a playground)
  --force Deploy API without confirming breaking changes
  --with-union-cache *Experimental:* Enable union cache that optimizes schema generation for schemas with many self-referencing types

Examples
  sanity graphql deploy
  sanity graphql deploy --playground
  sanity graphql deploy --generation gen1
  sanity graphql deploy --dataset staging --no-playground
  sanity graphql deploy --dataset staging --tag next --no-playground
  sanity graphql deploy --no-playground --force
  sanity graphql deploy --playground --non-null-document-fields

Deleting/undeploying an API

usage: sanity graphql undeploy undefined

   Remove a deployed GraphQL API

Options
  --dataset <dataset> Delete GraphQL API for the given dataset
  --tag <tag> Delete GraphQL API for the given tag (defaults to 'default')

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

Was this article helpful?