Skip to content

null lists of non primitive objects are not handled #355

@koblas

Description

@koblas

The following unit test demonstrates the problem:

func TestLists_NullableListOfInt_ReturnsNull(t *testing.T) {
    ttype := graphql.NewList(graphql.Int)
    type dataType *[]int

    var data dataType

    expected := &graphql.Result{
        Data: map[string]interface{}{
            "nest": map[string]interface{}{
                "test": nil,
            },
        },
    }
    checkList(t, ttype, data, expected)
}

Expected functionality is that "test" is nil, instead, an error is generated:

	got: [User Error: expected iterable, but did not find one for field DataType.test.]
	want: []

The problem is that isNullish() doesn't look at the interface pointer types. Potentially you should do a:

if !value.IsValid() {
   return false
} 

before the switch statement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions