Skip to content

BindFields: added default fields tag #589

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gstarikov
Copy link

hi. i didn't understand why it necessary to specify json tags for every field. so i added default values for BindFields function.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 92.43% when pulling 675936e on gstarikov:master into ba29b76 on graphql-go:master.

@williamhaley
Copy link

Agreed. I ran into this same issue today. The current behavior that requires specifying a tag is a bit intuitive. I think this PR makes a lot of sense. Is there anything I or others can do to help push this along?

FWIW, I tried a workaround in the meantime...

graphql.BindFields(CloneAndAddTags(myType{}))

With CloneAndAddTags I used reflection to dynamically clone the source struct Type and set the appropriate json tags so that BindFields could understand, but that failed. BindFields generates a resolver that invokes extractTag so my hack was doomed.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants