
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeWhen you're working with multiple workspaces in Sanity v3 and trying to deploy GraphQL APIs, you need to configure the graphql array in your sanity.cli.ts (or sanity.cli.js) file. This tells the CLI which workspaces should have GraphQL APIs deployed.
Here's how to fix the error:
In your sanity.cli.ts file, add a graphql array that maps to your workspaces:
import { defineCliConfig } from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: 'your-project-id',
dataset: 'production'
},
graphql: [
{
id: "production",
workspace: "production", // matches workspace name in sanity.config.ts
},
{
id: "staging",
workspace: "staging", // matches workspace name in sanity.config.ts
}
]
})Key points:
workspace property in each GraphQL config object must match the workspace names you've defined in your sanity.config.ts fileid property lets you identify each GraphQL API when deployingDeploying your GraphQL APIs:
Once configured, you can deploy GraphQL APIs in these ways:
# Deploy all GraphQL APIs
sanity graphql deploy
# Deploy only a specific API by its ID
sanity graphql deploy --api productionMake sure your workspace configurations are consistent between sanity.config.ts (where you define the workspaces) and sanity.cli.ts (where you configure the GraphQL APIs). The workspace names must match exactly for the CLI to properly associate each GraphQL API with its corresponding workspace.
You can find more details in the GraphQL documentation and the CLI GraphQL reference.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store