dangcuuson / graphql-schema-typescript

Generate TypeScript from GraphQL's schema type definitions
190 stars 36 forks source link

Graphql 15: Syntax Error: Unexpected Name "folder_name" #51

Closed samzmann closed 3 years ago

samzmann commented 3 years ago

I'm trying to generate my types with yarn graphql-schema-typescript generate-ts graphql and getting this error:

Message:  null
Error:  GraphQLError [Object]: Syntax Error: Unexpected Name "graphql".
    at syntaxError (/Users/sam/vytal/partner_app/node_modules/graphql/error/syntaxError.js:15:10)
    at Parser.unexpected (/Users/sam/vytal/partner_app/node_modules/graphql/language/parser.js:1482:41)
    at Parser.parseDefinition (/Users/sam/vytal/partner_app/node_modules/graphql/language/parser.js:155:16)
    at Parser.many (/Users/sam/vytal/partner_app/node_modules/graphql/language/parser.js:1537:26)
    at Parser.parseDocument (/Users/sam/vytal/partner_app/node_modules/graphql/language/parser.js:109:25)
    at parse (/Users/sam/vytal/partner_app/node_modules/graphql/language/parser.js:36:17)
    at Object.buildSchema (/Users/sam/vytal/partner_app/node_modules/graphql/utilities/buildASTSchema.js:116:36)
    at Object.<anonymous> (/Users/sam/vytal/partner_app/node_modules/graphql-schema-typescript/lib/index.js:94:42)
    at step (/Users/sam/vytal/partner_app/node_modules/graphql-schema-typescript/lib/index.js:40:23)
    at Object.throw (/Users/sam/vytal/partner_app/node_modules/graphql-schema-typescript/lib/index.js:21:53) {
  locations: [ { line: 1, column: 1 } ]
}

My gql config is located in graphql/graphql.config My project is using graphql: 15.3.0, node: 14.12.0

I have a very similar setup in another project that uses graphql: 14.7.0, and there everything works fine. When I use 14.7.0 in this project, ts type generation also works fine. So there must be some breaking changes in 14->15 that graphql-schema-typescript is not handling yet.

Any idea how to fix this without reverting my entire project back to graphql 14?

dangcuuson commented 3 years ago

Fixed on 1.5.1