gatsby-source-sanity
gatsby-source-sanity copied to clipboard
Documents with _type that matches Sanity’s predefined object types break builds
trafficstars
We had an instance where there was a document like this in the dataset:
{
"_createdAt": "<redacted>",
"_id": "<redacted>",
"_rev": "<redacted>",
"_type": "slug",
"_updatedAt": "<redacted>",
"current": "test"
}
Likely coming from adding an entry of the default objects that appear in the studio if no schema config is given. This confuses the source plugin, which then returns:
warning Type `SanitySlug` declared in `createTypes` looks like a node, but doesn't implement a `Node` interface. It's likely that you should add the `Node` interface to your type def:
`type SanitySlug implements Node { ... }`
If you know that you don't want it to be a node (which would mean no root queries to retrieve it), you can explicitly disable inference for it:
`type SanitySlug @dontInfer { ... }`
error Building schema failed
The best solution is probably to not show default object types in the studio in the first place, since you rarely want document representations of these. But we should consider if the source plugin should be able to anticipate that this can occur and at least give some helpful feedback to deal with it?