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.

optional chaining for graphql-language-service@5.0.0 breaks upstream build

See original GitHub issue

Hi,

We are using graphiql module in our app which takes the latest of 1.x.x version and since upgrading recently to 1.7.1 building graphql-language-service@5.0.0 is failing with the following reason:

16:39:07  Module parse failed: Unexpected token (45:28)
16:39:07  You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
16:39:07  |     if (kind === RuleKinds.IMPLEMENTS ||
16:39:07  |         (kind === RuleKinds.NAMED_TYPE &&
16:39:07  >             state.prevState?.kind === RuleKinds.IMPLEMENTS)) {
16:39:07  |         return getSuggestionsForImplements(token, state, schema, queryText, typeInfo);
16:39:07  |     }
16:39:07   @ ../node_modules/apiconnect-explorer/node_modules/graphql-language-service/esm/interface/index.js 2:0-45 2:0-45
16:39:07   @ ../node_modules/apiconnect-explorer/node_modules/graphql-language-service/esm/index.js
16:39:07   @ ../node_modules/apiconnect-explorer/node_modules/graphiql/esm/components/GraphiQL.js
16:39:07   @ ../node_modules/apiconnect-explorer/node_modules/graphiql/esm/index.js
16:39:07   @ ../node_modules/apiconnect-explorer/dist/es/components/TestToolGraphQL.js
16:39:07   @ ../node_modules/apiconnect-explorer/dist/es/components/GraphQLDisplay.js
16:39:07   @ ../node_modules/apiconnect-explorer/dist/es/components/Routing.js
16:39:07   @ ../node_modules/apiconnect-explorer/dist/es/App.js
16:39:07   @ ../node_modules/apiconnect-explorer/dist/es/Bootstrap.js

similar issue https://github.com/graphql/graphiql/issues/1852, but we are using webpack 4.x and babel 6.x, so wondering if it is something we need to resolve on our end by doing something like https://danw1ld.medium.com/optional-chaining-for-javascript-with-babel-7-and-webpack-4-2de8fd9dbdd5 to handle optional chaining or it can be resolved from the module itself?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
edwinckccommented, Mar 24, 2022

It looks like we’re still getting the same error on 1.7.2, with graphql-language-service "^5.0.1" 🤔

image
1reaction
acaocommented, Mar 23, 2022

every library from this repo that is universal or browser centric should use target es6 with typescript by default, which should not include optional chaining, as that is equivalent to es2015. we only override target to a later version for the LSP server, vscode-graphql and CLI, so there is something we are doing wrong here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Optional chaining (?.) - JavaScript - MDN Web Docs - Mozilla
The optional chaining (?.) operator accesses an object's property or calls a function. If the object accessed or function called is ...
Read more >
Optional chaining breaks build when targeting modern browsers
Bug Report Using the optional chaining operator causes the build to fail when targeting modern browsers through browserslist.
Read more >
5 Ways Converting to Optional Chaining Can Break Your Code
The optional chaining operator lets you write concise and safe chains of connected objects when some of those objects can be null or...
Read more >
Error while importing a module with optional chaining
We created the project using vue-cli and add the dependency to the library. We then imported a project (Vue Currency Input v2.0.0) that...
Read more >
What is wrong with optional chaining and how to fix it - DEV ...
Optional chaining simplifies above and removes a lot of errors by saying that values considered as no value are only two - null...
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