graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.91k stars 839 forks source link

Enhancement: BindFields should handle graphql: tag #472

Open koblas opened 5 years ago

koblas commented 5 years ago

The graphql.BindField() function only respects the json: tag. It would be useful if you could specify a different tag for graphql serialization.

Something like

type BaseStream struct {
    OriginalSize int32  `json:"original_size" graphql:"originalSize"`
    Resolution   string `json:"resolution"`                          
    SeriesType   string `json:"series_type" graphql:"seriesType"`     
}

Right now after creating an object with BindFields you get:

original_size: Int
resolution: String
series_type: String

This makes it possible to use a single model object to read a network request then modify it for GraphqQL serialisation.