diff --git a/graphql_test.go b/graphql_test.go index 8df3be7dd2..fd20d41ca6 100644 --- a/graphql_test.go +++ b/graphql_test.go @@ -1370,7 +1370,8 @@ func TestInput(t *testing.T) { boolean(value: true) nullable1: nullable(value: 42) nullable2: nullable(value: null) - list(value: [{v: 41}, {v: 42}, {v: 43}]) + list1: list(value: [{v: 41}, {v: 42}, {v: 43}]) + list2: list(value: {v: 42}) } `, ExpectedResult: ` @@ -1383,7 +1384,8 @@ func TestInput(t *testing.T) { "boolean": true, "nullable1": 42, "nullable2": null, - "list": [41, 42, 43] + "list1": [41, 42, 43], + "list2": [42] } `, }, diff --git a/internal/exec/packer.go b/internal/exec/packer.go index 5007dfd220..64601a934c 100644 --- a/internal/exec/packer.go +++ b/internal/exec/packer.go @@ -167,7 +167,11 @@ func (e *listPacker) pack(r *request, value interface{}) (reflect.Value, error) value = r.vars[string(v)] } - list := value.([]interface{}) + list, ok := value.([]interface{}) + if !ok { + list = []interface{}{value} + } + v := reflect.MakeSlice(e.sliceType, len(list), len(list)) for i := range list { packed, err := e.elem.pack(r, list[i])