Metriche repository
- Star
- (1310 star)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Is your feature request related to a problem? Please describe.
When the user doesn't have control over naming conventions in the GraphQL schema, using the generated code can be awkward when the schema does not use CamelCase field names.
For example, Hasura's naming convention is to use snake_case for fields, while go convention is lowerCamelCase (or CamelCase). Accessing those fields can result in generated code like the sample below, which is not idiomatic.
Describe the solution you'd like An option could be added for transformation of field names from other case types to camel case. This transformation would only be applied to Go field names and not the json tags. The option would be disabled by default to preserve backwards compatibility.
Adding such an option would allow users without control of the server to access field names using the conventional case.
Describe alternatives you've considered
- As far as I know, it's impossible to achieve this by preprocessing the schema.
- Postprocessing the generated code with gofmt seems brittle.
Additional context
The go protobuf compiler implements similar functionality: https://github.com/protocolbuffers/protobuf-go/blob/v1.28.0/compiler/protogen/protogen.go#L731-L746
I'd be happy to help implement this! I wanted to get input from the maintainers on if this feature is within scope and useful first.