gatsby: GraphQL problem parsing query in gatsby@2.18.20 and later

After upgrading from gatsby@2.18.19-jobs-api-v2.39 to gatsby@2.18.20 (and all later versions) I get this error

ERROR #85915 GRAPHQL There was a problem parsing the GraphQL query in file: src/components/Nav/index.js

The file in question looks pretty harmless. So maybe the changes introduced a bug? The log states:

Bug Fixes gatsby: Webpack /_ webpackPrefetch/webpackPreload _/ comments causing a bug (#20403) (1b89b10) Features gatsby: Allow alternative import syntax for useStaticQuery (#20330) (17eaa72)

#20330 sounds like it might be related.

Environment

`gatsby info --clipboard`

System: OS: macOS 10.15.3 CPU: (16) x64 Intel® Core™ i9-9880H CPU @ 2.30GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.1 - /usr/local/bin/node Yarn: 1.21.1 - /usr/local/bin/yarn npm: 6.13.6 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Chrome: 79.0.3945.130 Safari: 13.0.5 npmPackages: gatsby: 2.18.20 => 2.18.20 gatsby-image: 2.2.40 => 2.2.40 gatsby-plugin-algolia: ^0.5.0 => 0.5.0 gatsby-plugin-catch-links: 2.1.25 => 2.1.25 gatsby-plugin-favicon: ^3.1.6 => 3.1.6 gatsby-plugin-feed-mdx: ^1.0.1 => 1.0.1 gatsby-plugin-google-analytics: 2.1.35 => 2.1.35 gatsby-plugin-lodash: ^3.1.16 => 3.1.20 gatsby-plugin-manifest: 2.2.41 => 2.2.41 gatsby-plugin-mdx: ^1.0.59 => 1.0.70 gatsby-plugin-netlify-cache: ^1.2.0 => 1.2.0 gatsby-plugin-offline: 3.0.34 => 3.0.34 gatsby-plugin-react-helmet: 3.1.22 => 3.1.22 gatsby-plugin-sharp: 2.4.5 => 2.4.5 gatsby-plugin-styled-components: ^3.1.19 => 3.1.19 gatsby-remark-autolink-headers: ^2.1.19 => 2.1.24 gatsby-remark-code-titles: ^1.1.0 => 1.1.0 gatsby-remark-copy-linked-files: ^2.1.31 => 2.1.37 gatsby-remark-embed-video: 2.0.1 => 2.0.1 gatsby-remark-emojis: ^0.4.2 => 0.4.2 gatsby-remark-images: 3.1.44 => 3.1.44 gatsby-remark-katex: ^3.1.18 => 3.1.24 gatsby-remark-responsive-iframe: 2.2.32 => 2.2.32 gatsby-remark-smartypants: 2.1.21 => 2.1.21 gatsby-remark-sub-sup: ^1.0.0 => 1.0.0 gatsby-remark-vscode: ^2.0.1 => 2.0.1 gatsby-source-filesystem: 2.1.48 => 2.1.48 gatsby-transformer-sharp: 2.3.14 => 2.3.14 gatsby-transformer-yaml: 2.2.24 => 2.2.24

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 16 (10 by maintainers)

Most upvoted comments

I just upgraded one of my apps to gatsby@2.24.14 and have hit this issue. I appear to have the same problem that @kije hit.

I get this error

 ERROR #85915  GRAPHQL
[1] 
[1] There was a problem parsing the GraphQL query in file: /home/matt/dev/jumpclub/packages/web-client/src/play/playSlice.ts

But the file in question has no graphql in it at all. It does export a type along other things at the bottom of the file

type Foo = ...

export { stuff, Foo, otherStuff }

If I change it to

export type Foo = ...

export { stuff, otherStuff }

the issue goes away.

Yup, I’m getting what I expect as being a related issue. I’m unable to build with gatsby 2.19.7 as gatsby-source-contentful/src/fragments.js isn’t compatible.

Screenshot 2020-02-08 at 10 39 29 am

So this was happening because of this line:

export { NavLink } from './styles'

The new algorithm didn’t account for this case.

Here is an actual error (swallowed by gatsby catch block here):

TypeError: Cannot read property 'path' of undefined
    at followVariableDeclarations (janosh.io\node_modules\gatsby\dist\query\file-parser.js:330:47)
    at ExportSpecifier (janosh.io\node_modules\gatsby\dist\query\file-parser.js:346:31)
    at NodePath._call (janosh.io\node_modules\@babel\traverse\lib\path\context.js:55:20)
    at NodePath.call (janosh.io\node_modules\@babel\traverse\lib\path\context.js:42:17)
    at NodePath.visit (janosh.io\node_modules\@babel\traverse\lib\path\context.js:90:31)
    at TraversalContext.visitQueue (janosh.io\node_modules\@babel\traverse\lib\context.js:112:16)
    at TraversalContext.visitMultiple (janosh.io\node_modules\@babel\traverse\lib\context.js:79:17)
    at TraversalContext.visit (janosh.io\node_modules\@babel\traverse\lib\context.js:138:19)
    at Function.traverse.node (janosh.io\node_modules\@babel\traverse\lib\index.js:84:17)
    at traverse (janosh.io\node_modules\@babel\traverse\lib\index.js:66:12)
    at NodePath.traverse (janosh.io\node_modules\@babel\traverse\lib\path\index.js:148:24)
    at ExportNamedDeclaration (janosh.io\node_modules\gatsby\dist\query\file-parser.js:342:16)
    at NodePath._call (janosh.io\node_modules\@babel\traverse\lib\path\context.js:55:20)
    at NodePath.call (janosh.io\node_modules\@babel\traverse\lib\path\context.js:42:17)
    at NodePath.visit (janosh.io\node_modules\@babel\traverse\lib\path\context.js:90:31)
    at TraversalContext.visitQueue (janosh.io\node_modules\@babel\traverse\lib\context.js:112:16)

So it is definitely #20330 causing this.

CC @jfrolich