eddeee888 / graphql-code-generator-plugins

List of GraphQL Code Generator plugins that complements the official plugins.
MIT License
44 stars 10 forks source link

[BUG] Error in types.generated.ts when schema has interface Record #229

Open keckrich opened 5 months ago

keckrich commented 5 months ago

Describe the bug When a schema.graphql file has an interface called Record the types.generated.ts file with throw an error. In my case the first error is with export type WithIndex<TObject> = TObject & Record<string, any>; as well as: /** Mapping of interface types */ export type ResolversInterfaceTypes<RefType extends Record<string, unknown>> = ResolversObject<{

To Reproduce

  1. in the schema.graphql file make an interface with name 'Record'
  2. run graphql-codegen

Expected behavior I am currently getting around this by manually adding a TypeScriptRecord and updating where Record is called: `export type TypeScriptRecord<K extends string | number | symbol, T> = {

};`

Versions

eddeee888 commented 4 months ago

Hi @keckrich ,

Interesting problem! Looks like a clash in reserved keywords in TypeScript. I talked to someone at the Codegen team about this issue previously but I'm not sure when or what the fix would be 🙂.

Do you mind creating an issue at https://github.com/dotansimha/graphql-code-generator instead please? If it's implemented there, it would just work with the preset in this repo. 🙂