Skip to content

Commit db6bc15

Browse files
committed
Adds regression test for #439.
1 parent 0beacfd commit db6bc15

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

executor_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,62 @@ func TestMergesParallelFragments(t *testing.T) {
297297
}
298298
}
299299

300+
type CustomMap map[string]interface{}
301+
302+
func TestCustomMapType(t *testing.T) {
303+
query := `
304+
query Example { data { a } }
305+
`
306+
data := CustomMap{
307+
"a": "1",
308+
"b": "2",
309+
}
310+
schema, err := graphql.NewSchema(graphql.SchemaConfig{
311+
Query: graphql.NewObject(graphql.ObjectConfig{
312+
Name: "RootQuery",
313+
Fields: graphql.Fields{
314+
"data": &graphql.Field{
315+
Type: graphql.NewObject(graphql.ObjectConfig{
316+
Name: "Data",
317+
Fields: graphql.Fields{
318+
"a": &graphql.Field{
319+
Type: graphql.String,
320+
},
321+
"b": &graphql.Field{
322+
Type: graphql.String,
323+
},
324+
},
325+
}),
326+
Resolve: func(p graphql.ResolveParams) (interface{}, error) {
327+
return data, nil
328+
},
329+
},
330+
},
331+
}),
332+
})
333+
if err != nil {
334+
t.Fatalf("Error in schema %v", err.Error())
335+
}
336+
337+
result := testutil.TestExecute(t, graphql.ExecuteParams{
338+
Schema: schema,
339+
Root: data,
340+
AST: testutil.TestParse(t, query),
341+
})
342+
if len(result.Errors) > 0 {
343+
t.Fatalf("wrong result, unexpected errors: %v", result.Errors)
344+
}
345+
346+
expected := map[string]interface{}{
347+
"data": map[string]interface{}{
348+
"a": "1",
349+
},
350+
}
351+
if !reflect.DeepEqual(result.Data, expected) {
352+
t.Fatalf("Expected context.key to equal %v, got %v", expected, result.Data)
353+
}
354+
}
355+
300356
func TestThreadsSourceCorrectly(t *testing.T) {
301357

302358
query := `

0 commit comments

Comments
 (0)