Troubleshooting warning for documents not declared in GraphQL schema during Gatsby build

9 replies
Last updated: Apr 28, 2020
I see the following warning for 3 documents during `gatsby build`:
[sanity] Document "fbca6239-40f3-4c6b-b197-224106c7fb38" has type position (SanityPosition), which is not declared in the GraphQL schema. Make sure you run "graphql deploy". Skipping document.
How do I find that document within Sanity?
AI Update

You can find that document in Sanity Studio by navigating directly to it using the document ID in the URL. Here are a few ways to locate it:

Method 1: Direct URL (fastest)

Add the document ID to your Studio URL like this:

https://your-studio.sanity.studio/desk/fbca6239-40f3-4c6b-b197-224106c7fb38

Replace your-studio.sanity.studio with your actual Studio URL. This will open the document directly if it exists.

Method 2: Vision Plugin (if installed)

If you have the Vision plugin installed in your Studio, you can run a GROQ query to find the document:

*[_id == "fbca6239-40f3-4c6b-b197-224106c7fb38"]

This will return the document and show you all its fields, including the _type.

Method 3: API Query

You can also query for it using the Sanity CLI or HTTP API:

sanity documents get fbca6239-40f3-4c6b-b197-224106c7fb38

About the warning itself:

The warning indicates that you have a document of type position (with schema name SanityPosition) that exists in your dataset, but it's not included in your GraphQL schema deployment. To fix this, you need to:

  1. Make sure the position schema type is defined in your Studio's schema files
  2. Run sanity graphql deploy to update your GraphQL API with the current schema

If you've removed this document type from your schema but the documents still exist, you may want to delete them or migrate them to a different type. The direct URL method above will let you view and delete the document if needed.

Hi Chandler, if
position
is a document type you have recently created but not yet deployed, try running
sanity graphql deploy
. If it’s a leftover from the past, I guess you could either delete these documents via the CLI (
sanity documents delete <doc-id>
) or create a new
position
document type just so you can review the past items and then remove as necessary.
ah, thanks. I think deleting them works fine.
I’ve run the
graphql deploy
several times so I think the delete command is what I need.
If you don’t have a document type called
position
in your schema at the moment, the deploy command will not resolve the issue in this case, which is what might be going on. These seem to be former documents added when there was still a
position
doc type.
That makes sense
I think these were leftovers from our initial setup or from following a tutorial of some sort.
(You can still view them if you re-create that type, in case there’s information in there you might need.)
¯\_(ツ)_/¯ already deleted them
🤠

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.

Was this answer helpful?