Graphql query for optional field for childImageSharp #23499
Labels
stale?
Issue that may be closed soon due to the original author not responding any more.
type: question or discussion
Issue discussing or asking a question about Gatsby
I have a blog with posts and previews for this posts. In my blog listing I query for this images like that:
And in my post I'm using fields like that:
All is working except case when none of my posts has coverImg field with valid path to the file in it. Gatsby throws an error:
I've related issues about Contentful, but didn't understand how to define properly type to make Graphql return null for
coverImg
field instead of this error.Forgot to mention that I'm using gatsby theme as plugin, so this might be my issue: #15544 (comment)
I did some research and added this to my content site's
gatsby-node.js
:And now Gatsby throws an error:
You can test it yourself in my theme repo: https://github.com/Defite/gatsby-theme-defite/tree/theme-v2
The text was updated successfully, but these errors were encountered: