-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add json tags to gql_mutation_input #551
base: master
Are you sure you want to change the base?
Conversation
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.
This change is backwards incompatible, isn't it? I think we need an option to enable/disable or configure the tag.
entgql/template.go
Outdated
// | ||
// FullName => fullName | ||
// ID => iD | ||
func decap(s string) string { |
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.
The generated names are available here: https://github.com/ent/contrib/blob/master/entgql/schema.go#L578-L594. We should bind them to the template data when generating these types (or the WhereInput) either statically or by template function.
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.
Sounds good, I will update.
@masseelch Sure, I can do that. Where would the configuration option live? |
@a8m @masseelch Changes requested have been implemented on this PR, and also I gated the feature behind a feature flag added in this PR: ent/ent#3808 Thanks again for reviewing :) |
Hi all, @a8m @masseelch is there any way I can help push this PR through? |
I've run into this same issue using gqlgenc to generate a client. I can autobind to the input types that entgql creates and the generated client uses them, but since they don't have json tags the request fails when the request body is marshalled out because the field names are not lower camel case. It would be really nice to get this PR merged so that we don't need workarounds to use the generated input types. As a workaround I'm using gomodifytags to add the json tags. This is easy to automate but it would be great if the generated mutation input structs came with the tags. Here's an example of the command I'm using:
|
I'll join the others and mention that PR would be helpful for internal graphql tests when we want to send to a local grapgql client:
it's only a matter of As @philip-peterson took care of, PR is backwards compatible. @a8m notice that contrib/entgql/internal/todo/todo_test.go Line 94 in 37281ef
|
Should solve ent/ent#3086
Similar to #550
Here's an example generated struct:
from this source: