Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

Hey all! I'm a Sanity newbie and trying to add Sanity to a Gatsby project I'm working on. I'm trying to add the gatsby-sanity-source plugin and when I try and build the project...

3 replies
Last updated: Jan 28, 2021

Hey all! I'm a Sanity newbie and trying to add Sanity to a Gatsby project I'm working on. I'm trying to add the gatsby-sanity-source plugin and when I try and build the project I get this gnarly error.

Failed to validate error Error [ValidationError]: child "error" fails because ["error" must be an object]

If I remove the plugin code from gatsby-config. It builds fine. The plugin objectlooks like this (I removed the projectId from this message):


{
resolve: 'gatsby-source-sanity',
options: {
projectId: 'my-id',
dataset: 'production',

// a token with read permissions is required

// if you have a private dataset

token: <http://process.env.MY|process.env.MY>_SANITY_TOKEN,

},

},

Any ideas what I'm missing?

Jan 28, 2021, 8:27 PM

I’m not too familiar with GraphQL, but did you run

sanity graphql deploy
?

Jan 28, 2021, 8:37 PM

Yea I would try what Geoff just said - especially since your trace is throwing this:

error: 'Error: GraphQL API not deployed - see <https://github.com/sanity-io/gatsby-source-sanity#graphql-api> for more info\n

Jan 28, 2021, 8:41 PM

Yup, that was it. I tried that yesterday and it came back and said that graphql wasn't an available switch (or something like that) for sanity.Anyways it worked now! Onward I go and THANK YOU!!

Jan 28, 2021, 8:54 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.