Skip to content

Commit

Permalink
added nonNilExec
Browse files Browse the repository at this point in the history
  • Loading branch information
neelance committed Oct 21, 2016
1 parent c12a8ad commit 2966f21
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2966f21

Please sign in to comment.