-
Notifications
You must be signed in to change notification settings - Fork 494
Closed
Description
Not support map[string]interface{} type.
example:
scalar Map
schema {
query: Query
}
type Query {
run(data: Map): Map
}
I have this code:
type Map struct {
value interface{}
}
// ImplementsGraphQLType i
func (Map) ImplementsGraphQLType(name string) bool {
return name == “Map”
}
// UnmarshalGraphQL is
func (j *Map) UnmarshalGraphQL(input interface{}) error {
j.value = input.(map[string]interface{})
return nil
}
// MarshalJSON is
func (j Map) MarshalJSON() ([]byte, error) {
return json.Marshal(j.value)
}
type Resolver struct{}
// Run is
func (r *Resolver) Run(ctx context.Context, args struct {
Data *Map
}) *Map {
return args.Data
}
The query is:
{
run(data:{a:123456} )
}
The error is:
{
“errors”: [
{
“message”: “Argument \“data\” has invalid value {a: 123456}.\nExpected type \“Map\“, found {a: 123456}.“,
“locations”: [
{
“line”: 2,
“column”: 12
}
]
}
]
}
And I expect this:
{
“data”: {
“run”: {
“a”: 123456
}
}
}
Metadata
Metadata
Assignees
Labels
No labels