Error deploying new version of graphql API due to missing Sanity studio file
I understand how frustrating this error is! The "Expected Sanity studio of version 3 or above" message when deploying GraphQL can be confusing, especially since your packages clearly show Studio v3 installed.
Based on the GraphQL deployment documentation, here are the most likely causes and solutions:
1. Check your sanity.cli.js configuration
The sanity graphql deploy command requires a properly configured sanity.cli.js (or sanity.cli.ts) file in your project root with API credentials:
import { defineCliConfig } from 'sanity/cli'
export default defineCliConfig({
api: {
projectId: 'your-project-id',
dataset: 'production'
}
})If this file is missing or doesn't have the api.projectId configured, the CLI can't properly detect your project setup, which may trigger version detection issues.
2. Verify you're in the correct directory
Make sure you're running the command from your Sanity project root directory (where your schema files and configuration are located), not from a parent or subdirectory.
3. Try specifying the dataset explicitly
Run the deploy command with explicit parameters:
sanity graphql deploy --dataset production4. Check if you have workspace configurations
If you're using multiple workspaces, you may need to configure GraphQL deployment in your sanity.cli.js to specify which workspace to deploy:
export default defineCliConfig({
api: {
projectId: 'your-project-id',
dataset: 'production'
},
graphql: [
{
id: "production",
workspace: "production",
}
]
})5. Try a fresh install
Sometimes dependency issues can cause detection problems:
rm -rf node_modules package-lock.json
npm install
sanity graphql deployThe error message suggests the CLI is having trouble detecting your Studio v3 setup, which is typically a configuration file issue rather than a package version problem. Once your sanity.cli.js is properly configured with the required API settings, the GraphQL deployment should work correctly.
Sanity – Build the way you think, not the way your CMS thinks
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.