dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.85k stars 1.33k forks source link

Allow generating scalar typecasts #7587

Open NuckChorris opened 2 years ago

NuckChorris commented 2 years ago

Is your feature request related to a problem? Please describe.

The scalar configuration of the typescript plugin allows setting the generated type annotations but doesn't actually do any casts. This results in a mismatch between the annotated type and the real type (ie, a field is marked as a Date when it's actually still a DateTime String from graphql-scalars)

Describe the solution you'd like

Allow me to pass functions for casting scalars, to be applied whenever the scalar is in the return schema. Ideally with an easy shortcut for the graphql-scalars library because they're both projects of The Guild!

Describe alternatives you've considered

denis-sokolov commented 1 year ago

Related: #5949, #2684.