You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing a Gatsby Theme I customized the GraphQL schema (gatsby-node.js). This works as expected with all fields except the cover front matter field used for a cover image. If I omit the cover image on all posts the site still builds but if there are no posts at all I receive the following error message:
GraphQLError: Cannot query field "childImageSharp" on type "File"
Thanks for reporting this! The issue is that currently child* fields are not automatically created when we have no nodes for that type in the data layer. But we now have a childOf extension to explicitly define those parent/child relations. See #16109
A quick unrelated comment on the type defs in your theme's gatsby-node.js:
the Fields type should not implement the Node interface. Only top-level types, i.e. those created by source/transformer plugins should do that. (you'll see that currently you have fields and allFields root query types)
Description
While developing a Gatsby Theme I customized the GraphQL schema (gatsby-node.js). This works as expected with all fields except the
cover
front matter field used for a cover image. If I omit the cover image on all posts the site still builds but if there are no posts at all I receive the following error message:GraphQLError: Cannot query field "childImageSharp" on type "File"
Steps to reproduce
git clone https://github.com/ryanwiemer/gatsby-theme-amsterdam
yarn install
content
folder insite/content/
yarn workspace site develop
- To start development using the site folderGraphQLError: Cannot query field "childImageSharp" on type "File"
Expected result
Since I defined the schema through the Schema Customization I expect the site to build even when there is no content.
Actual result
The site fails to build.
Environment
System:
OS: macOS High Sierra 10.13.6
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 12.6.0 - /var/folders/v8/dxrbb0vj7z9dtxj7mq5tc101d1qq1d/T/yarn--1564090827764-0.3745122210652396/node
Yarn: 1.17.3 - /var/folders/v8/dxrbb0vj7z9dtxj7mq5tc101d1qq1d/T/yarn--1564090827764-0.3745122210652396/yarn
npm: 6.10.2 - /usr/local/bin/npm
Languages:
Python: 2.7.10 - /usr/bin/python
Browsers:
Chrome: 75.0.3770.142
Firefox: 67.0.4
Safari: 12.1.2
The text was updated successfully, but these errors were encountered: