Skip to content

Commit

Permalink
fixes "invalids declared but not used"
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman A. Grigorovich committed Dec 14, 2022
1 parent 0855439 commit e46df4b
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions codegen/object.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec
})
{{end}}
out := graphql.NewFieldSet(fields)
var invalids uint32
{{- if not $object.Root }}
var invalids uint32
{{- end }}
for i, field := range fields {
{{- if $object.Root }}
innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{
Expand All @@ -54,14 +56,16 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec
}
}()
res = ec._{{$object.Name}}_{{$field.Name}}(ctx, field{{if not $object.Root}}, obj{{end}})
{{- if $field.TypeReference.GQL.NonNull }}
if res == graphql.Null {
{{- if $object.IsConcurrent }}
atomic.AddUint32(&invalids, 1)
{{- else }}
invalids++
{{- end }}
}
{{- if not $object.Root }}
{{- if $field.TypeReference.GQL.NonNull }}
if res == graphql.Null {
{{- if $object.IsConcurrent }}
atomic.AddUint32(&invalids, 1)
{{- else }}
invalids++
{{- end }}
}
{{- end }}
{{- end }}
return res
}
Expand All @@ -88,14 +92,16 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec
out.Values[i] = ec._{{$object.Name}}_{{$field.Name}}(ctx, field, obj)
{{end}}

{{- if $field.TypeReference.GQL.NonNull }}
if out.Values[i] == graphql.Null {
{{- if $object.IsConcurrent }}
atomic.AddUint32(&invalids, 1)
{{- else }}
invalids++
{{- end }}
}
{{- if not $object.Root }}
{{- if $field.TypeReference.GQL.NonNull }}
if out.Values[i] == graphql.Null {
{{- if $object.IsConcurrent }}
atomic.AddUint32(&invalids, 1)
{{- else }}
invalids++
{{- end }}
}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
Expand Down

0 comments on commit e46df4b

Please sign in to comment.