-
Notifications
You must be signed in to change notification settings - Fork 846
Open
Labels
Description
I know that if I had a struct like this:
type User struct {
Username *string `json:"username"`
Age *int `json:"age"`
}
Then I could simply define a type with a field called "username"
and a type of graphql.String
and then another field "age"
with a type of graphql.Int
and the fields would "auto-resolve". However, I've been defining GraphQL types for AWS API return values and AWS uses a lot of pointers in their structs. For example their IDs/Names are an 'aws.String' which is basically *string
so the pointer address is returned in the GraphQL response. Obviously this is not what is desired, but it's odd to have this all over the place:
// ...
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
source := params.Source.(*User)
return *source.Username, nil
}
// ...
Resolve: func(params graphql.ResolveParams) (interface{}, error) {
source := params.Source.(*User)
return *source.Age, nil
}
Do you think the standard Scalar types should support pointers as well? Or should there be a wrapper type like Type: graphql.NewPointer(...)
?