graphql-go / graphql

An implementation of GraphQL for Go / Golang
MIT License
9.9k stars 841 forks source link

Add pointer support to resolve struct #139

Open arvitaly opened 8 years ago

arvitaly commented 8 years ago

Hi, what about pointers in struct, which resolves: type Todo struct { Text *string 'json:"text"' }

Resolve: func(params graphql.ResolveParams) (interface{}, error) { var text = "text1" return Todo{Text:&text} } Now, graphql returns "pointer as string", because the serialize function looks: fmt.Sprintf("%v", value)

I think, it is not the right way, what about this fix?

https://github.com/graphql-go/graphql/commit/d3df014b0d6417430740da6e4fd5b75cfa862ffe

diegomarangoni commented 7 years ago

+1 I think serialization should use JSON Text Marshal.