Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliased pointer types become pointer addresses #488

Open
atombender opened this issue Jun 14, 2019 · 0 comments · May be fixed by #489
Open

Aliased pointer types become pointer addresses #488

atombender opened this issue Jun 14, 2019 · 0 comments · May be fixed by #489

Comments

@atombender
Copy link
Contributor

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.

atombender added a commit to atombender/graphql that referenced this issue Jun 14, 2019
with "type MyInt int", values of type MyInt and *MyInt should be treated
as ints. Fixes graphql-go#488.
atombender added a commit to atombender/graphql that referenced this issue Jun 14, 2019
with "type MyInt int", values of type MyInt and *MyInt should be treated
as ints. Fixes graphql-go#488.
atombender added a commit to atombender/graphql that referenced this issue Jun 14, 2019
with "type MyInt int", values of type MyInt and *MyInt should be treated
as ints. Fixes graphql-go#488.
atombender added a commit to atombender/graphql that referenced this issue Jun 14, 2019
with "type MyInt int", values of type MyInt and *MyInt should be treated
as ints. Fixes graphql-go#488.
simaotwx pushed a commit to toowoxx/go-graphql that referenced this issue Mar 15, 2021
with "type MyInt int", values of type MyInt and *MyInt should be treated
as ints. Fixes graphql-go#488.

Signed-off-by: Simao Gomes Viana <simao.gomes@toowoxx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant