-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use exact capitalization from field names overridden in config #2237
Conversation
Thanks! Nice catch! |
@@ -29,7 +29,7 @@ | |||
{{- with .Description }} | |||
{{.|prefixLines "// "}} | |||
{{- end}} | |||
{{ $field.Name|go }} {{$field.Type | ref}} `{{$field.Tag}}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is this because of a bug in the go
filter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, the go
filter was just being erroneously applied in situations where the field name and its capitalization were being explicitly overridden in the gqlgen config. This was a problem because that filter changes the capitalization of field names that are already valid in Go in a slightly opinionated way, which was unwanted behavior in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. Cool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ianling Is there a way (in config or otherwise) to disable this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YogeshLele disable what exactly? If you want to specify a particular capitalization for a field in your schema, this PR made it so you can do so without gqlgen overriding it.
Will this work for the cases of enums ? |
Closes #1447
Behavior prior to this PR: given the following schema and gqlgen config:
Schema:
gqlgen.yml:
gqlgen generates the following Go struct:
Behavior after this PR (modelgen strictly adheres to field names overridden in the config):
Field names that are not overridden in the config will be exactly the same as before this PR, so users will only see different behavior if they had an overridden name that happened to fall into one of these funny capitalization edge cases.
I have:
Updated any relevant documentation (see docs)(not necessary)