graphql-go / graphql-go/graphql

Aliased pointer types become pointer addresses

Open
#488 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
10.1k
Forks
845
PR merge metrics
No merged PRs in 30d

Description

Test case:

```go
package main

import (
"context"
"encoding/json"
"fmt"
"log"

"github.com/graphql-go/graphql"
)

type Value string

func main() {
s, err := graphql.NewSchema(graphql.SchemaConfig{
Query: graphql.NewObject(graphql.ObjectConfig{
Name: "RootQuery",
Fields: graphql.Fields{
"value": &graphql.Field{
Type: graphql.String,
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
v := Value("hello")
return &v, nil
},
},
},
}),
})
if err != nil {
log.Fatal(err)
}

result := graphql.Do(graphql.Params{
Schema: s,
RequestString: "query MyQuery { value } ",
Context: context.TODO(),
})

fmt.Printf("%#v\n", result.Data)
}
```

This prints

```go
map[string]interface {}{"value":"0xc00000f500"}
```

instead of the expected:

```go
map[string]interface {}{"value":"hello"}
```

Annoyingly, there's no way to work around this by implementing `MarshalJSON` on `Value`, since it seems graphql-go doesn't use it.

I'll see if I can create a PR.

Related to #199.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.