Skip to content

Commit

Permalink
fix(gatsby): remove redundant dispatch of query extraction error (#28676
Browse files Browse the repository at this point in the history
) (#28744)

* fix(gatsby): remove redundant query extraction error dispatch

* Warning message

(cherry picked from commit 1d7dc76)

Co-authored-by: Vladimir Razuvaev <vladimir.razuvaev@gmail.com>
  • Loading branch information
GatsbyJS Bot and vladar authored Dec 23, 2020
1 parent 5a0489d commit 0b8ea51
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions e2e-tests/mdx/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
path: `${__dirname}/src/posts`,
},
},
`gatsby-plugin-test-regression1`,
{
resolve: `gatsby-plugin-mdx`,
options: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// See pages/regressions/index.mdx
exports.preprocessSource = args => args.contents
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"name": "gatsby-plugin-test-regression1"
}
10 changes: 10 additions & 0 deletions e2e-tests/mdx/src/pages/regressions/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
This is a regression test for query extraction bug in Gatsby.

All of the following is required to hit this bug:

1. There should be at least one other plugin implementing `preprocessSource`
2. This plugin must be listed before `gatsby-plugin-mdx` in `gatsby-config.js`
3. MDX file must contain word `graphql`

!Important, do not remove the next line!
`graphql`
5 changes: 1 addition & 4 deletions packages/gatsby/src/query/file-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,7 @@ async function parseToAst(filePath, fileStr, { parentSpan, addError } = {}) {
ast = tmp
break
} catch (error) {
boundActionCreators.queryExtractionGraphQLError({
componentPath: filePath,
})
continue
// We emit the actual error below if every transpiled variant fails to parse
}
}
if (ast === undefined) {
Expand Down

0 comments on commit 0b8ea51

Please sign in to comment.