hasura / go-graphql-client

Package graphql provides a GraphQL client implementation.
MIT License
405 stars 94 forks source link

fix dynamic GraphQLType interface #56

Closed hgiasac closed 1 year ago

hgiasac commented 1 year ago

close https://github.com/hasura/go-graphql-client/issues/48

Because the query parser infers and creates a new instance from the reflection type, it doesn't work if the GetGraphQLType method returns the dynamic type of struct property from the input variable.

type customTypeHint struct {
    Hint string
}

func (cth *customTypeHint) GetGraphQLType() string {
    return cth.hint
}

q := queryArguments(variables map[string]interface{} {
  "foo": customTypeHint{ Hint: "bar" }
})

// expected
// $foo:bar!

// actual
// $foo:!