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

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?