Skip to content

Commit

Permalink
Handle nillable list elements
Browse files Browse the repository at this point in the history
  • Loading branch information
wilhelmeek committed Mar 6, 2021
1 parent 997da42 commit 45903a6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions codegen/type.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,11 @@
ctx := graphql.WithFieldContext(ctx, fc)
f := func(i int) {
defer func() {
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if r := recover(); r != nil {
ec.Error(ctx, ec.Recover(ctx, r))
ret = nil
}
}()
if !isLen1 {
defer wg.Done()
}
Expand All @@ -107,9 +107,16 @@
}
{{ else }}
ret[i] = ec.{{ $type.Elem.MarshalFunc }}(ctx, sel, v[i])
{{- end}}
{{- end }}
}
{{ if not $type.IsScalar }} wg.Wait() {{ end }}
{{ if $type.Elem.NonNull }}
for _, e := range ret {
if e == graphql.Null {
return graphql.Null
}
}
{{ end }}
return ret
{{- else }}
{{- if $type.IsNilable }}
Expand Down

0 comments on commit 45903a6

Please sign in to comment.