graphql icon indicating copy to clipboard operation
graphql copied to clipboard

BindFields: added default fields tag

Open gstarikov opened this issue 5 years ago • 2 comments

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

gstarikov avatar Dec 14 '20 20:12 gstarikov

Coverage Status

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

coveralls avatar Dec 14 '20 20:12 coveralls

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.

williamhaley avatar Jan 12 '21 23:01 williamhaley