question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ERROR #85923 GRAPHQL: Type inference not working for gatsby >= 2.21.3

See original GitHub issue

Description

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:closed
  • Created 3 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

7reactions
zeajuniordevcommented, May 23, 2021

Hi! Any solution for this issue?. I use Gatsby CLI version: 3.1.0

1reaction
vladarcommented, May 4, 2020

@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

Read more comments on GitHub >

github_iconTop Results From Across the Web

How I Fixed: Gatsby GraphQL Cannot query field "query" on ...
The typeName and fieldName are important though. And my lack of use are what caused my problem. Inside my gatsby-node.js file I had...
Read more >
Troubleshooting Common Errors - Gatsby
If this is the case, when Gatsby constructs a GraphQL schema it may infer the wrong type because the empty string doesn't look...
Read more >
TypeError: Cannot read properties of undefined (reading ...
Hi , I am using Gatsby 4 and I am getting following error when I run gatsby develop ERROR #85923 GRAPHQL There was...
Read more >
ERROR #85923 GRAPHQL : r/gatsbyjs - Reddit
There was an error in your GraphQL query: Cannot query field "references" on type "ContentfulPostContent". " Help me.
Read more >
Ashvin Motye on Twitter: "How I fixed #Gatsby "ERROR ...
How I fixed #Gatsby "ERROR #85923 GRAPHQL There was an error in your #GraphQL query" with a dummy content workaround. ashvinmotye.com.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found