0

In our team we sometimes get an GraphQl syntax error, when modifying our schema.

However, we don't seem to get the name of file causing the issue? The error looks like this:

GraphQLError: Syntax Error: Unterminated string.
    at syntaxError (<full-path-to-project>>node_modules/graphql/error/syntaxError.js:15:10)
    at readString (<full-path-to-project>>node_modules/graphql/language/lexer.js:513:38)
    at readToken (<full-path-to-project>>node_modules/graphql/language/lexer.js:267:14)
    at Object.lookahead (<full-path-to-project>>node_modules/graphql/language/lexer.js:54:43)
    at Object.advanceLexer [as advance] (<full-path-to-project>>node_modules/graphql/language/lexer.js:44:33)
    at Parser.parseStringLiteral (<full-path-to-project>>node_modules/graphql/language/parser.js:519:17)
    at Parser.parseDescription (<full-path-to-project>>node_modules/graphql/language/parser.js:728:19)
    at Parser.parseFieldDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:856:28)
    at Parser.optionalMany (<full-path-to-project>>node_modules/graphql/language/parser.js:1497:28)
    at Parser.parseFieldsDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:846:17)
    at Parser.parseObjectTypeDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:798:23)
    at Parser.parseTypeSystemDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:696:23)
    at Parser.parseDefinition (<full-path-to-project>>node_modules/graphql/language/parser.js:146:23)
    at Parser.many (<full-path-to-project>>node_modules/graphql/language/parser.js:1518:26)
    at Parser.parseDocument (<full-path-to-project>>node_modules/graphql/language/parser.js:111:25)
    at parse (<full-path-to-project>>node_modules/graphql/language/parser.js:36:17) {
  message: 'Syntax Error: Unterminated string.',
  locations: [ { line: 27, column: 51 } ]
}

Is this normal - and how do I get the file causing the problem?

DauleDK
  • 3,313
  • 11
  • 55
  • 98
  • 2
    There's not a good way to check where the error is originating if your schema is split across multiple files. Check whatever files were changes since your last commit and look at line 27 where the syntax error actually is. You also find it helpful to use an editor plugin that offers syntax highlighting for GraphQL files (VS Code has one, I think so does IntelliJ, maybe others). – Daniel Rearden Jan 25 '20 at 13:36
  • Hi @DanielRearden - ok, thank you for letting me know that. It's a shame it's not possible in the current version. In the end, the error originated because I was actually not compiling my typescript files – DauleDK Jan 25 '20 at 16:25
  • you can also try [this answer](https://stackoverflow.com/a/10419288/6024220) to lengthen your stack trace. Whether that'll work depends on how you're merging the schema files. – Daniel Rearden Jan 25 '20 at 17:31

0 Answers0