
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeI can help you with this! The issue you're experiencing is a common one when changing from a string type to a slug type in Sanity. The problem is that in GraphQL, when a field is a slug type, it becomes an object with subfields (specifically slug.current), not a plain string.
The Core Issue
When you query a slug field in GraphQL, you need to access the current property because Sanity's slug type is an object with this structure:
{
"_type": "slug",
"current": "your-slug-value"
}How to Fix Your Gatsby Queries
You need to update your GraphQL queries in Gatsby. Change from:
{
allSanityYourType {
nodes {
slug // This won't work anymore
}
}
}To:
{
allSanityYourType {
nodes {
slug {
current // Access the current property
}
}
}
}About sanity graphql deploy
Yes, running sanity graphql deploy again is definitely necessary! This is a crucial step that many developers miss. According to the Sanity documentation, every time you update your Sanity schema (not just the content), you need to re-deploy the GraphQL API for the changes to be reflected.
Steps to Resolve:
sanity graphql deploy from your studio folder to update the GraphQL schemaslug.current instead of just slugnode.slug becomes node.slug.current)Note About Gatsby Integration
The gatsby-source-sanity plugin works by first fetching the GraphQL Schema Definitions from Sanity's deployed GraphQL API, which is why redeploying is essential. Without redeploying, Gatsby is still working with the old schema definition where slug was a string.
Running sanity deploy (for your Studio) is separate from sanity graphql deploy and won't update your GraphQL schema, so make sure you've run the GraphQL-specific deploy command.
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