2

I am using Contentful and Gatsby on my current project. I keep getting this error when I try and run my queries: TypeError: Could not find field type.

This happens on this rich text field if it is empty on Contentful's side. I do not have this issue if I add some data. This is the query fragment:

   description {
        childMarkdownRemark {
          rawMarkdownBody
        }
      }

How do I handle this? Can I specify that I want this to come back as null or an empty string?

Danny
  • 77
  • 1
  • 8
  • 2
    I believe this is an open issue still. There are work arounds but it doesn't look simple to implement. it is being discussed here. https://github.com/gatsbyjs/gatsby/issues/3344 – Stefan T Feb 11 '20 at 06:18
  • GraphQL builds its schema using data it finds in the sources provided - fields that exist but contain no data anywhere in the source are not included as there's no point fetching a field that never contained data in the first place. In your query, if you attempt to pull in data for a field that doesn't exist in the GraphQL schema, it will fail with an error like `Cannot query field \"nonExistentField\" on type \"thing\"`. Check out GraphiQL if you aren't already (`http://localhost:8000/___graphql` when you're running Gatsby locally), it gives you a look at the schema structure. – Timmah Feb 15 '23 at 22:46

0 Answers0