ERROR #85923 GRAPHQL: Type inference not working for gatsby >= 2.21.3
See original GitHub issueDescription
After updating to gatsby version >=2.21.3
, gatsby develop
throws many errors of type ERROR #85923 GRAPHQL
: There was an error in your GraphQL query during step “extract queries from components”. Interestingly, gatbsy build
works as expected.
Steps to reproduce
$ git clone -b issue-gatsby-23633 https://github.com/styxlab/gatsby-starter-try-ghost.git
$ cd gatsby-starter-try-ghost
$ yarn
$ gatsby develop
Error log starting here:
success run queries - 0.717s - 28/28 39.08/s
warn Plugin `gatsby-transformer-rehype` tried to define the GraphQL type
ERROR #85923 GRAPHQL
There was an error in your GraphQL query:
Cannot query field "icon" on type "GhostSettings".
If you don't expect "icon" to exist on the type "GhostSettings" it is most likely a typo.
However, if you expect "icon" to exist there are a couple of solutions to common problems:
- If you added a new data source and/or changed something inside gatsby-node.js/gatsby-config.js, please try a restart of your development server
- The field might be accessible in another subfield, please try your query in GraphiQL and use the GraphiQL explorer to see which fields you can query and what shape they have
- You want to optionally use your field "icon" and right now it is not used anywhere. Therefore Gatsby can't infer the type and add it to the GraphQL schema. A quick fix is to add a least one entry with that field ("dummy content")
It is recommended to explicitly type your GraphQL schema if you want to use optional fields. This way you don't have to add the mentioned "dummy content". Visit our docs to learn how you can define the schema for "GhostSettings":
https://www.gatsbyjs.org/docs/schema-customization/#creating-type-definitions
File: node_modules/gatsby-theme-try-ghost/src/components/common/HeaderIndex.js:49:9
Note that gatsby build
doesn’t throw any errors and that the produced build is working as expected.
Expected result
gatsby develop
should be able to infer the types as it did before.
Workaround
Ensure gatsby version <=2.21.1
Related Issues
I thought that I’d be hit by issue #23472 but the fix should be already in the latest gastby build and the errors shown above still persist. Latest version that I tested was 2.21.6
.
New open Issue #23632 looks similar in its symptoms.
Comparison between version 2.21.1
and 2.21.3
:
By looking through the changes between the working and not working version, my hunch is that the changes in inference-metadata.js are causing the issue.
Environment
System: OS: Linux 5.5 Fedora 30 (Workstation Edition) 30 (Workstation Edition) CPU: (8) x64 Intel® Core™ i7-3770K CPU @ 3.50GHz Shell: 5.0.11 - /bin/bash Binaries: Node: 12.16.2 - /usr/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm Languages: Python: 2.7.17 - /usr/bin/python Browsers: Chrome: 81.0.4044.122 Firefox: 75.0 npmGlobalPackages: gatsby-cli: 2.11.14
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
Hi! Any solution for this issue?. I use Gatsby CLI version: 3.1.0
@styxlab This may still break in other edge cases if not fixed in
gatsby-source-ghost
.P.S. Created an issue: https://github.com/TryGhost/gatsby-source-ghost/issues/44