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

Warn on GraphQL parser exceptions #642

Merged
merged 1 commit into from
Nov 14, 2018
Merged

Conversation

hekard2l
Copy link
Contributor

When GraphQL parse fails to parse file(s) errors are silently ignored.

Was having an issue with a whitespace character in one of our .graphql files which was rather difficult to trace. This character is added as a result of saving the file in XCode, so it'd be a common use case.

Example:

Warning: error parsing GraphQL file "Queries/Enrollments.graphql"
Syntax Error: Cannot contain the invalid character "\u0010".

Queries/Enrollments.graphql (6:1)
5: }
6: 
^
7: 

at syntaxError (/../code/apollo-cli/node_modules/graphql/error/syntaxError.js:24:10)
at readToken (/../code/apollo-cli/node_modules/graphql/language/lexer.js:174:34)
at Object.lookahead (/../code/apollo-cli/node_modules/graphql/language/lexer.js:61:43)
at Object.advanceLexer [as advance] (/../code/apollo-cli/node_modules/graphql/language/lexer.js:52:33)
at skip (/../code/apollo-cli/node_modules/graphql/language/parser.js:1284:11)
at many (/../code/apollo-cli/node_modules/graphql/language/parser.js:1349:11)
at parseSelectionSet (/../code/apollo-cli/node_modules/graphql/language/parser.js:272:17)
at parseOperationDefinition (/../code/apollo-cli/node_modules/graphql/language/parser.js:209:19)
at parseExecutableDefinition (/../code/apollo-cli/node_modules/graphql/language/parser.js:166:16)
at parseDefinition (/../code/apollo-cli/node_modules/graphql/language/parser.js:132:16)

The stacktrace isn't useful, but e.message does not contain the filename, line number and preview.

Fix silent parsing failure

When GraphQL `parse` fails to parse a file errors are silently
ignored.

Was having an issue with a whitespace character in one of our
`.graphql` files which was rather difficult to trace.
@apollo-cla
Copy link

@hekard2l: Thank you for submitting a pull request! Before we can merge it, you'll need to sign the Meteor Contributor Agreement here: https://contribute.meteor.com/

@jbaxleyiii
Copy link
Contributor

@hekard2l this is awesome! Thank you so much!

@jbaxleyiii jbaxleyiii merged commit 9c9b406 into apollographql:master Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants