CannotQuery Field [Field] on type [Type]
This is a classic GraphQL schema deployment issue! When you add new fields to your Sanity schema, the GraphQL API doesn't automatically know about them - you need to redeploy your GraphQL schema.
The error "Cannot query field [field] on type [Type]" happens because your GraphQL API generates its schema based on your Sanity content models, but it only updates when you explicitly deploy it. So even though your new fields exist in your Sanity schema and Studio, the GraphQL endpoint is still using the old schema definition.
To fix this, run:
sanity graphql deployThis command regenerates and deploys your GraphQL schema based on your current Sanity schema, making all your new fields queryable.
Why this happens:
Unlike GROQ (Sanity's native query language), which dynamically queries whatever exists in your documents, GraphQL requires a predefined schema that must be explicitly deployed. This gives you benefits like type safety and schema introspection, but means you need to redeploy whenever your content model changes.
Pro tip: Make it a habit to run sanity graphql deploy after any schema changes if you're using GraphQL. Some teams even add this to their deployment pipeline to ensure the GraphQL schema stays in sync with their content model.
If you're running into this frequently and want more flexibility, you might also consider using GROQ instead, which doesn't require this deployment step since it queries the content dynamically. You can even use both in the same project depending on your needs!
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.