New field in Sanity schema not appearing in GraphQL API
Great that you solved it! For anyone else running into this issue, here's what's likely happening:
When you add a new field to your Sanity schema, you need to redeploy your GraphQL endpoint by running:
sanity graphql deployThis is a separate step from deploying your Studio or rebuilding your Gatsby site. The GraphQL API is generated from your schema, so every time you make schema changes (adding/removing fields, changing types, etc.), you need to redeploy it.
Why this matters for Gatsby:
The gatsby-source-sanity plugin works by first fetching the GraphQL Schema Definitions from Sanity's deployed GraphQL API, then streaming all accessible documents to Gatsby's in-memory datastore. Without redeploying the GraphQL API, the plugin won't know about your new field.
Common workflow when adding new fields:
- Add the field to your schema (like your
siteURLfield) - Run
sanity graphql deployfrom your Studio directory - Update content in Studio
- Rebuild your Gatsby site
Pro tip: You can use sanity graphql deploy --dry-run to validate your schema changes before deploying, which will catch any breaking changes without actually deploying.
Note: While gatsby-source-sanity uses the deployed GraphQL API for schema definitions, Sanity also supports querying directly with GROQ if you prefer that approach. But if you're using the standard GraphQL setup with Gatsby, the sanity graphql deploy step is essential after schema changes.
Show original thread12 replies
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.