Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trailing semicolon in #import 'someFile.gql'; causes cryptic error message #813

Open
maslade opened this issue Mar 6, 2024 · 1 comment
Labels

Comments

@maslade
Copy link

maslade commented Mar 6, 2024

Ask me how I know :) It looks like these import statements are meant to tolerate content after the module path, with the specific exception of a semicolon.

#import 'myFragment.gql';

Produces this error:

ERROR in ./src/TheQuery.gql 21:104
Module parse failed: Unexpected token (21:104)
File was processed with these loaders:
 * ./node_modules/graphql-tag/loader.js
You may need an additional loader to handle the result of these loaders.
|       )
|     }
>   doc.definitions = doc.definitions.concat(unique(require('MyFragment.gql';).definitions));
| 

The message does include the problem, but is a little hard to parse. Once I realized my semicolon was the problem, I noticed it in the above message as well.

This seems to be unintentional, as otherwise the #import directive tolerates extra junk after the path string. From experimenting, these were all okay:

#import 'MyQuery.gql' ;
#import 'MyQuery.gql' -- extra things

If it is intentional, I think an improvement to the error message would be helpful.

@jerelmiller
Copy link
Member

Thanks for opening @maslade! I'd agree that the error is a bit hard to parse here and its not obvious the semicolon is to blame.

I don't have a guess on when we'd be able to fix this, but wanted to at least acknowledge this issue. Thanks for reporting!

@jerelmiller jerelmiller added the bug label Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants