Skip to content

Aliased pointer types become pointer addresses #488

Open
@atombender

Description

@atombender

Test case:

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

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

instead of the expected:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions