graphql-tag
graphql-tag copied to clipboard
Trailing semicolon in `#import 'someFile.gql';` causes cryptic error message
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.
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!