From 1a9a41b9c10d6c08fe9c55bb99cc95964ee6cab4 Mon Sep 17 00:00:00 2001 From: "Roman A. Grigorovich" Date: Wed, 14 Dec 2022 17:22:00 +0300 Subject: [PATCH] Fix issue #2470 --- codegen/field.gotpl | 4 +++- codegen/object.gotpl | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/codegen/field.gotpl b/codegen/field.gotpl index e47b958ddac..3daaa596f02 100644 --- a/codegen/field.gotpl +++ b/codegen/field.gotpl @@ -26,7 +26,9 @@ func (ec *executionContext) _{{$object.Name}}_{{$field.Name}}(ctx context.Contex }) if err != nil { ec.Error(ctx, err) - return {{ $null }} + {{- if not $object.Root }} + return {{ $null }} + {{- end }} } {{- end }} if resTmp == nil { diff --git a/codegen/object.gotpl b/codegen/object.gotpl index 1fbdfacec14..74b2b2bd7ee 100644 --- a/codegen/object.gotpl +++ b/codegen/object.gotpl @@ -104,7 +104,9 @@ func (ec *executionContext) _{{$object.Name}}(ctx context.Context, sel ast.Selec } } out.Dispatch() - if invalids > 0 { return graphql.Null } + {{- if not $object.Root }} + if invalids > 0 { return graphql.Null } + {{- end }} return out } {{- end }}