Graphql-code-generator: ts1005 error with declarationKind: class

Created on 10 Dec 2019  路  11Comments  路  Source: dotansimha/graphql-code-generator

config:
  declarationKind:
    input: 'class'

Results in classes being generated with commas instead of semicolons at end of lines, resulting in TypeScript compilation errors: TS1005: ';' expected

As a concrete example:

export class SomeInput {
  code: Scalars['String'], // should be ;
};
bug plugins waiting-for-release

All 11 comments

It's actually more than that, we need to have declare class in some way (but then it limits the type of the file we can use), and have special care of scalars type. I'll take a look soon :)

Thanks @andreialecu

In my case, simply replacing all commas with semicolons makes everything work properly, but I'm not using any custom scalar types, just the built in ones.

@andreialecu can you please share the complete (fixed) output? so I'll be able to test that directly in TS Playground.
Thanks

@dotansimha I'm not sure what you mean, the only problem with the output with this config

overwrite: true
schema: "http://localhost:1338/graphql"
documents: "./source/**/*.graphql"
config:
  declarationKind:
    input: 'class'
generates:
  source/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-apollo-angular"
  ./graphql.schema.json:
    plugins:
      - "introspection"

Is the comma at end of class declarations instead of a semicolon. Everything else is fine, and I have a pretty big graphql schema. The generated graphql.ts file is over 1000 lines long. Everything is fine except for those lines.

Here's an example from the generated output.

image

I see, but I suspect Scalars might cause issues with other TypeScript configurations, that's why I asked for the complete file, I want to verify that.

I'm facing the same issue and here's the complete output with scalars class
image

@dinana @andreialecu I think I managed to fix that issue in: https://github.com/dotansimha/graphql-code-generator/pull/3183

Can you please try 1.9.2-alpha-f125efa1.44?

Fixed in v1.10.0.

Helo, @dotansimha .

I think the issue is not solved yet, v1.10.0 and even later version still generates comma(,) instead of semicolon(;).

Would you please look at this issue?

@ggomma I'm working on it, almost done.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

quolpr picture quolpr  路  3Comments

fvisticot picture fvisticot  路  3Comments

steebchen picture steebchen  路  3Comments

iamdanthedev picture iamdanthedev  路  3Comments

mdaouas picture mdaouas  路  3Comments