graphql-js: Unclear Error Output on Language/Parser.js
I’m assuming I introduced the following error, but it seems to originate deep within the module and is not clear on exactly what it is that’s failing
/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:966 throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token)); ^ GraphQLError at syntaxError (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/error/syntaxError.js:28:15) at expect (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:966:32) at parseFieldDefinition (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:715:3) at any (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:1002:16) at parseObjectTypeDefinition (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:683:16) at parseTypeSystemDefinition (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:607:16) at parseDefinition (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:148:16) at parseDocument (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:106:22) at parse (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/language/parser.js:43:10) at buildSchema (/home/zmg/Thinkful/Goalzapp/server/node_modules/graphql/utilities/buildASTSchema.js:461:43) at Object.<anonymous> (/home/zmg/Thinkful/Goalzapp/server/index.js:15:16) at Module._compile (module.js:571:32) at Object.Module._extensions..js (module.js:580:10) at Module.load (module.js:488:32) at tryModuleLoad (module.js:447:12) at Function.Module._load (module.js:439:3)
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 15 (4 by maintainers)
Commits related to this issue
- fixed app crashing, source: https://github.com/graphql/graphql-js/issues/743 — committed to rmisu/book-search-engine by rmisu 2 years ago
@leebyron
I’m able to repro this in one instance:
Naively, I removed an argument from one of the sub-types in my schema but left the parens, like this:
Notice users and allOrders. Removing the offending empty parens fixes the error below:
thanks alot @idibidiart
issue in my case was that i didn’t add a type for lauches after the colon. expected graphql to have pointed me to where my error is coming from though, instead, i its points to a line parser.js
your answer pointed me to the right direction 😎
Strange that you’re not seeing the message of the syntax error, which is what I see when I run a test like
require('graphql').parse('{{')
:Also, if you’re calling
parse()
directly, then I recommend catching the parser errors and handling them in a more convenient way, such as: