👀 Our most exciting product launch yet 🚀 Join us May 8th for Sanity Connect

Issue with Gatsby and Sanity connection, resolved with a workaround.

6 replies
Last updated: May 13, 2022
Well, I’ve been over this and over this researching, implementing and testing and I can’t seem to figure it out, so I’m asking for help. As best as I can figure, something I did disconnected my graphql for Gatsby from my Sanity when I was launching to Netlify. I’m just trying to reconnect them at this point, Before I tried to launch my GraphiQL showed the
allSanityHomepage
kind of data, but now all the Sanity data is not connected. I was able to successfully launch my Sanity to Netlify, so it’s live at a custom domain. My
gatsby-config.js
is set up with the correct projectId, dataset and token - I’ve triple checked and I have used
sanity graphql deploy
(more than once at this point) - the playground does contain all the data correctly too. I think that is all the relevant information. Does anyone have an idea of where I go from here?
May 12, 2022, 1:56 PM
Hey Eric! Maybe it's an issue with your
gatsby-source-sanity
implementation? How do you have it configured?
May 12, 2022, 6:47 PM
Thanks for responding, Racheal. Here’s my
gatsby-config.js
for this plugin:
 require('dotenv').config({
  path: `.env`,
});

module.exports = {
  /* Your site config here */
  plugins: [
    {
      resolve: 'gatsby-source-sanity',
      options: {
        projectId: process.env.SANITY_PROJECT_ID,
        dataset: process.env.SANITY_DATASET,
        apiVersion: '2021-09-01',
        watchMode: true,
        token: process.env.SANITY_TOKEN,
      },
    },
  ],
}
May 12, 2022, 8:01 PM
I’ve set up a basic environment with only the Gatsby v4 hello world starter,
gatsby-source-sanity
and
gatsby-plugin-sanity-image
and this is what I get when I run
gatsby develop
:
ERROR 

Missing onError handler for invocation 'building-schema', error was 'Error: Type with name "GatsbyImageLayout" does not exists'.
 Stacktrace was 'Error: Type with name "GatsbyImageLayout" does not exists
    at SchemaComposer.get (/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/TypeStorage.ts:39:13)
    at ThunkComposer._thunk (/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/TypeMapper.ts:737:34)
    at ThunkComposer.get ofType [as ofType]
(/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/ThunkComposer.ts:21:34)
    at getTypeNode (/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/definitionNode.ts:253:28)
    at /Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/definitionNode.ts:286:20
    at Array.map (<anonymous>)
    at getArgumentsDefinitionNodes
(/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/definitionNode.ts:284:6)
    at /Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/definitionNode.ts:320:20
    at Array.map (<anonymous>)
    at getFieldDefinitionNodes
(/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/definitionNode.ts:312:6)
    at getObjectTypeDefinitionNode
(/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/definitionNode.ts:61:13)
    at ObjectTypeComposer.getType
(/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/ObjectTypeComposer.ts:986:57)
    at getGraphQLType (/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/utils/typeHelpers.ts:308:17)
    at /Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/SchemaComposer.ts:227:47
    at Array.forEach (<anonymous>)
    at SchemaComposer.buildSchema
(/Users/ericphifer/Desktop/gatsby-prlogin/node_modules/graphql-compose/src/SchemaComposer.ts:226:31)'

⠇ building schema
The building schema never completes
May 12, 2022, 8:18 PM
Ok, I figured out the issue with this last one in my test environment with Gatsby v4. I have it running and can access Sanity data through GraphiQL. I’m going to try to migrate my site files and see if I can get this launched to Netlify. I’ll update if I can…
May 12, 2022, 9:18 PM
This solution did work - I still don’t know why exactly it broke but it works now. Thank you for your help!
May 13, 2022, 8:39 PM
Glad you got it sorted out!
May 13, 2022, 8:40 PM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?