ardeois / graphql-codegen-typescript-mock-data

[GraphQL Codegen Plugin](https://github.com/dotansimha/graphql-code-generator) for building mock data based on the schema.
MIT License
134 stars 46 forks source link

feat: support casting enum values as types #150

Closed rickdunkin closed 10 months ago

rickdunkin commented 10 months ago

I would like to be able to use the useTypeImports: true option while also mocking enums. I can use the enumsAsTypes: true option, but the enum isn't currently imported as a type, and the string literal isn't typed correctly as the appropriate enum.

I've added a new option castEnumsAsTypes to be used along with enumsAsTypes in order to cast the string values of enums to their correct type. Maybe this shouldn't be a separate option, or perhaps the option should have a different name. I considered having this functionality be the default if both useTypeImports and enumsAsTypes are true, but I went with a new option as I don't know how folks are using this library.

rickdunkin commented 10 months ago

The new config option is removed