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

Fails with wrong error when graphql file has syntax error #42

Open
ldiqual opened this issue Mar 3, 2020 · 2 comments
Open

Fails with wrong error when graphql file has syntax error #42

ldiqual opened this issue Mar 3, 2020 · 2 comments

Comments

@ldiqual
Copy link

ldiqual commented Mar 3, 2020

When trying to generate typescript code from an invalid graphql file:

$ graphql-schema-typescript generate-ts generate-ts src/chema.graphql
Message:  null
Error:  { GraphQLError: Syntax Error: Cannot parse the unexpected character "/".
    at syntaxError (/Users/ldiqual/Siteline/siteline/node_modules/graphql/error/syntaxError.js:15:10)
    at readToken (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/lexer.js:270:38)
    at Object.lookahead (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/lexer.js:54:43)
    at Object.advanceLexer [as advance] (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/lexer.js:44:33)
    at Parser.expectToken (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/parser.js:1398:19)
    at Parser.many (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/parser.js:1514:10)
    at Parser.parseDocument (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/parser.js:111:25)
    at parse (/Users/ldiqual/Siteline/siteline/node_modules/graphql/language/parser.js:36:17)
    at Object.buildSchema (/Users/ldiqual/Siteline/siteline/node_modules/graphql/utilities/buildASTSchema.js:462:43)
    at Object.<anonymous> (/Users/ldiqual/Siteline/siteline/node_modules/graphql-schema-typescript/lib/index.js:98:42)
  message: 'Syntax Error: Cannot parse the unexpected character "/".',
  locations: [ { line: 1, column: 1 } ] }

What happens is that https://github.com/dangcuuson/graphql-schema-typescript/blob/master/src/index.ts#L53 parses the schema file from a path, and it throws because there's a syntax error, but then the error is silenced and the code tries to parse the actual path string, which results in the error above.

@thanhdongnguyen
Copy link

This is deviated version of graphql. Downgrade version suit with graphql-schema-typescript. Example my version graphql-schema-typescript is 1.2.9, i use graphql version 14.0.1

@gabsprates
Copy link

Same problem here. It would be good update graphql dependency version

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

No branches or pull requests

3 participants