diff --git a/internal/exec/exec.go b/internal/exec/exec.go index 461a58cf685..8f34a8f6f40 100644 --- a/internal/exec/exec.go +++ b/internal/exec/exec.go @@ -98,7 +98,13 @@ func makeExec(s *schema.Schema, t schema.Type, resolverType reflect.Type, typeRe }, nil case *schema.NonNull: - return makeExec(s, t.Elem, resolverType, typeRefMap) + e, err := makeExec(s, t.Elem, resolverType, typeRefMap) + if err != nil { + return nil, err + } + return &nonNilExec{ + elem: e, + }, nil case *schema.TypeReference: if scalar, ok := scalarTypes[t.Name]; ok { @@ -456,6 +462,15 @@ type typeAssertExec struct { typeExec *typeRefExec } +type nonNilExec struct { + elem iExec +} + +func (e *nonNilExec) exec(r *request, selSet *query.SelectionSet, resolver reflect.Value) interface{} { + // TODO ensure non-nil result + return e.elem.exec(r, selSet, resolver) +} + func skipByDirective(r *request, d map[string]*query.Directive) bool { if skip, ok := d["skip"]; ok { if execValue(r, skip.Arguments["if"]).(bool) {