
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeThis is a common caching issue with Gatsby! When you add new fields to your Sanity schema, Gatsby doesn't automatically pick them up because it caches the GraphQL schema and data from previous builds.
Here's what you need to do:
1. Run gatsby clean
This is the most important step. Run this command in your Gatsby project directory:
gatsby cleanThis clears Gatsby's cache and the .cache directory, forcing it to rebuild the GraphQL schema from scratch on the next build.
2. Redeploy your GraphQL API (if using GraphQL)
If you're using gatsby-source-sanity with the GraphQL API, you need to redeploy your schema:
cd your-sanity-studio
sanity graphql deployThis updates the GraphQL API that Gatsby queries to include your new field definitions.
3. Restart your Gatsby development server
After cleaning the cache, restart your dev server:
gatsby developWhy this happens:
The gatsby-source-sanity plugin fetches your Sanity GraphQL schema definitions and streams documents into Gatsby's in-memory datastore. When you add new fields, Gatsby's cached schema doesn't know about them until you clean the cache and rebuild.
Additional troubleshooting:
style field is actually populated in your Sanity documents (not just in the schema)overlayDrafts: true in your gatsby-config.js, ensure you have a read token configured to see draft contentstyle fieldAfter running gatsby clean and restarting, your new style field should appear in your Gatsby queries!
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