error: Syntax Error: Expected Name, found $
See original GitHub issueDescribe the bug
when running the gql-gen
tool on the schema.json
file below I get the error: error: Syntax Error: Expected Name, found $
and nothing else, all other tools iv tried out does not give me any errors, so I am clueless on how to find the actual error here… a better error message could maybe help?
I have used GraphQL Playground and Apollo Engine to try and look for errors in the scema, but no luck…
To Reproduce Steps to reproduce the behavior:
- Use schema.json as Schema
- Run the following command:
gql-gen --schema schema.json --template graphql-codegen-typescript-template --out types.ts
Expected behavior
A types.ts
file that compiles.
Environment:
- OS: Windows 10
- Codegen: 0.10.7
- Node: 10.0.0
DEBUG Output debug.log
Issue Analytics
- State:
- Created 5 years ago
- Comments:23 (10 by maintainers)
Top Results From Across the Web
GraphQL gql Syntax Error: Expected Name, found
This error occurs mostly when there are unclosed curly braces or when some fields are not properly defined while calling the query.
Read more >Syntax Error: Expected Name, found $ · Issue #180 - GitHub
I have the following code: import gql from 'graphql-tag'; export const USER_QUERY = gql `{ query User($id: ID!) { getUser(id: id) { name...
Read more >AppSync GraphQL syntax error: 'Expected Name, found String'
the error says you send a string where it expects a value with type name. the name is probably an enum so you...
Read more >graphqlerror: syntax error: expected name, found "!". - You.com
This error occurs mostly when there are unclosed curly braces or when some fields are not properly defined while calling the query. Open...
Read more >Syntax Error: Expected Name, found EOF - GraphQL - YouTube
While working with GraphQL, found that I had missed the curly braces in the query statement.#graphql # error #expressjs #nodejs #javascript.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@furier , If you do have GraphQL documents, you can try v0.12.4. Thanks to @jonaskello , now the error are printed in a better and readable way, and it’s pointing to the file with the errors.
@furier The change that was made was that each file is validated against the schema separately in order to be able to print which file caused which error.
Before all graphql from all files were concatenated into one big AST and then that was validated. This made it possible to find all fragments as they existed in the single AST, however it made it impossible to know which file caused which validation error. So we got some errors but no clue in which file it occured.
With the change we can trace all validation errors to files, however we cannot fully validate cases where a file imports a fragment from another file as that now will result in an unknown fragment error. This is because fragments are not resolved which I think they should be, but until then I think my quickfix would make it possible for you to run again.