-
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
Finds fields by configurable struct tag #308
Conversation
This is a bit magical, why #212 doesn't really explain this use case though, this seems to be the reverse (binding not generating models).
|
I used |
Priority is a bit weird here too, consider struct Thing {
Bar string `json: "foo"`
Foo string `json: "bar"`
} which should be used? Also, what should happen to struct Thing {
A string `json: "foo"`
B string `json: "foo"`
} |
The current priority is that tags take least priority, this is a departure from how JSON encoding works now, I think it would be better to follow the std lib and the tags would have higher precedence over struct field names. I would consider the second case I bug and maybe some check could be added for this case? |
That's not quite true, because they currently take priority at a field level (its happening in the same loop) For the first example, I think I'm open to this, if its gated behind some opt in config for which key to use. Also needs some tests. |
@codyleyhan Could you post a small example showing a possible use case of this feature? |
Finds fields by configurable struct tag
Adds the ability to bind fields for resolvers based on gated struct tag that is provided in the
gqlgen.yml
file.The binding now occurs in the following order when a struct tag is passed:
Also errors when struct tags would cause ambiguous binding such as two tags having the same value.
I have: