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
133 stars 47 forks source link

Preserving underscores #60

Closed sebvilhelm closed 2 years ago

sebvilhelm commented 2 years ago

Hi, thank you for creating this plugin 🙏

I've encountered a minor discrepancy with the @graphql-codegen/typescript plugin, while adding this plugin to our setup:

The official typescript plugin defaults to preserving underscores when creating types based on a GraphQL schema, as documented under namingConvention on this page. Our GraphQL endpoint stitches all our microservices schemas, prefixing with the service name, making the underscore a very welcome addition when we reference types in our code, but right now this is conflicting with the case transform for this plugin.

Can a similar transformUnderscores option be added to this plugin?

The most straight forward implementation, I think, would be to reimplement this piece of code: https://github.com/dotansimha/graphql-code-generator/blob/6734c58055d283f051bf32f115f2308000e56431/packages/plugins/other/visitor-plugin-common/src/utils.ts#L253-L262

ardeois commented 2 years ago

Good point @VilhelmNielsen that could be a nice improvement. I don't have time this week to work on this, but PRs are welcomed 🙂