Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema Customization - Cannot Query Field "childImageSharpe" on type "File" #16099

Closed
ryanwiemer opened this issue Jul 25, 2019 · 2 comments · Fixed by #16109
Closed

Schema Customization - Cannot Query Field "childImageSharpe" on type "File" #16099

ryanwiemer opened this issue Jul 25, 2019 · 2 comments · Fixed by #16109

Comments

@ryanwiemer
Copy link
Contributor

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

  1. git clone https://github.com/ryanwiemer/gatsby-theme-amsterdam
  2. yarn install
  3. Remove the content folder in site/content/
  4. yarn workspace site develop - To start development using the site folder
  5. You should now see the error message: GraphQLError: 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

@stefanprobst
Copy link
Contributor

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)

@ryanwiemer
Copy link
Contributor Author

@stefanprobst Thank you for the quick response!

Also thank you for the tip on my type definitions. I will fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants