Skip to content

Commit

Permalink
implement union type
Browse files Browse the repository at this point in the history
  • Loading branch information
pugovok committed Feb 9, 2021
1 parent b20b6e0 commit 0290bcb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,12 @@ func (r *Request) execSelectionSet(ctx context.Context, sels []selected.Selectio
return
}

if s.ExtResolver != nil {
if v, ok := s.ExtResolver[t.String()]; ok {
resolver = reflect.NewAt(v.Elem().Type(), unsafe.Pointer(resolver.Elem().UnsafeAddr()))
}
}

r.execSelections(ctx, sels, path, s, resolver, out, false)
return
}
Expand Down
3 changes: 3 additions & 0 deletions internal/exec/resolvable/resolvable.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ func (b *execBuilder) makeExec(t common.Type, resolverType reflect.Type, ext map
return b.makeObjectExec(t.Name, t.Fields, t.PossibleTypes, nonNull, resolverType, ext)

case *schema.Union:
if v, ok := ext[t.Name]; ok {
resolverType = reflect.TypeOf(v)
}
return b.makeObjectExec(t.Name, nil, t.PossibleTypes, nonNull, resolverType, ext)
}

Expand Down

0 comments on commit 0290bcb

Please sign in to comment.