question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

error: Syntax Error: Expected Name, found $

See original GitHub issue

Describe 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:

  1. Use schema.json as Schema
  2. 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:closed
  • Created 5 years ago
  • Comments:23 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
dotansimhacommented, Sep 18, 2018

@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.

1reaction
jonaskellocommented, Sep 18, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found