From f1eafcb8f08010103a6ef633cac1d29d87b22a48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=9A?= =?UTF-8?q?=D1=80=D1=83=D0=BF=D1=8F=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Thu, 19 Sep 2024 14:08:56 +0300 Subject: [PATCH] Fix marhaling interfaces and unions --- .../federation/accounts/graph/generated.go | 8 +-- .../federation/products/graph/generated.go | 8 +-- .../federation/reviews/graph/generated.go | 16 +++--- _examples/selection/generated.go | 8 +-- _examples/starwars/generated/exec.go | 20 +++---- _examples/type-system-extension/generated.go | 8 +-- codegen/interface.gotpl | 2 +- .../followschema/interfaces.generated.go | 34 +++++------ .../followschema/useptr.generated.go | 8 +-- .../followschema/validtypes.generated.go | 8 +-- codegen/testserver/singlefile/generated.go | 50 ++++++++--------- graphql/jsonw.go | 17 ++---- .../computedrequires/generated/exec.go | 56 +++++++++---------- .../testdata/entityresolver/generated/exec.go | 56 +++++++++---------- .../explicitrequires/generated/exec.go | 56 +++++++++---------- 15 files changed, 174 insertions(+), 181 deletions(-) diff --git a/_examples/federation/accounts/graph/generated.go b/_examples/federation/accounts/graph/generated.go index 5a786e3b80e..2a88aa1a6da 100644 --- a/_examples/federation/accounts/graph/generated.go +++ b/_examples/federation/accounts/graph/generated.go @@ -3087,12 +3087,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return graphql.Null case model.EmailHost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "EmailHost"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._EmailHost(ctx, sel, &obj) case *model.EmailHost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "EmailHost"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -3100,12 +3100,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._EmailHost(ctx, sel, obj) case model.User: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._User(ctx, sel, &obj) case *model.User: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/_examples/federation/products/graph/generated.go b/_examples/federation/products/graph/generated.go index 85e376a248b..94e7362991f 100644 --- a/_examples/federation/products/graph/generated.go +++ b/_examples/federation/products/graph/generated.go @@ -3175,12 +3175,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return graphql.Null case model.Manufacturer: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Manufacturer"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Manufacturer(ctx, sel, &obj) case *model.Manufacturer: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Manufacturer"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -3188,12 +3188,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._Manufacturer(ctx, sel, obj) case model.Product: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Product"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Product(ctx, sel, &obj) case *model.Product: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Product"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/_examples/federation/reviews/graph/generated.go b/_examples/federation/reviews/graph/generated.go index aa4cea40f04..5df2deda771 100644 --- a/_examples/federation/reviews/graph/generated.go +++ b/_examples/federation/reviews/graph/generated.go @@ -3463,12 +3463,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return graphql.Null case model.EmailHost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "EmailHost"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._EmailHost(ctx, sel, &obj) case *model.EmailHost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "EmailHost"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -3476,12 +3476,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._EmailHost(ctx, sel, obj) case model.Manufacturer: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Manufacturer"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Manufacturer(ctx, sel, &obj) case *model.Manufacturer: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Manufacturer"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -3489,12 +3489,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._Manufacturer(ctx, sel, obj) case model.Product: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Product"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Product(ctx, sel, &obj) case *model.Product: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Product"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -3502,12 +3502,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._Product(ctx, sel, obj) case model.User: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._User(ctx, sel, &obj) case *model.User: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/_examples/selection/generated.go b/_examples/selection/generated.go index 461d2543f75..ea6ccb12575 100644 --- a/_examples/selection/generated.go +++ b/_examples/selection/generated.go @@ -2656,12 +2656,12 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob return graphql.Null case Post: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Event", "Post"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Post(ctx, sel, &obj) case *Post: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Event", "Post"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -2669,12 +2669,12 @@ func (ec *executionContext) _Event(ctx context.Context, sel ast.SelectionSet, ob return ec._Post(ctx, sel, obj) case Like: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Event", "Like"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Like(ctx, sel, &obj) case *Like: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Event", "Like"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/_examples/starwars/generated/exec.go b/_examples/starwars/generated/exec.go index 562d609285a..c83c3a04c58 100644 --- a/_examples/starwars/generated/exec.go +++ b/_examples/starwars/generated/exec.go @@ -5252,12 +5252,12 @@ func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet return graphql.Null case models.Human: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Character", "Human"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Human(ctx, sel, &obj) case *models.Human: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Character", "Human"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5265,12 +5265,12 @@ func (ec *executionContext) _Character(ctx context.Context, sel ast.SelectionSet return ec._Human(ctx, sel, obj) case models.Droid: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Character", "Droid"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Droid(ctx, sel, &obj) case *models.Droid: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Character", "Droid"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5287,12 +5287,12 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection return graphql.Null case models.Human: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"SearchResult", "Human"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Human(ctx, sel, &obj) case *models.Human: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"SearchResult", "Human"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5300,12 +5300,12 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection return ec._Human(ctx, sel, obj) case models.Droid: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"SearchResult", "Droid"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Droid(ctx, sel, &obj) case *models.Droid: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"SearchResult", "Droid"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5313,12 +5313,12 @@ func (ec *executionContext) _SearchResult(ctx context.Context, sel ast.Selection return ec._Droid(ctx, sel, obj) case models.Starship: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"SearchResult", "Starship"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Starship(ctx, sel, &obj) case *models.Starship: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"SearchResult", "Starship"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/_examples/type-system-extension/generated.go b/_examples/type-system-extension/generated.go index 49311fb5cf5..cd223b02470 100644 --- a/_examples/type-system-extension/generated.go +++ b/_examples/type-system-extension/generated.go @@ -2856,12 +2856,12 @@ func (ec *executionContext) _Data(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null case Todo: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Data", "Todo"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Todo(ctx, sel, &obj) case *Todo: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Data", "Todo"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -2878,12 +2878,12 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null case Todo: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Node", "Todo"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Todo(ctx, sel, &obj) case *Todo: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Node", "Todo"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/codegen/interface.gotpl b/codegen/interface.gotpl index 93654e69720..35bb8e94e22 100644 --- a/codegen/interface.gotpl +++ b/codegen/interface.gotpl @@ -7,7 +7,7 @@ func (ec *executionContext) _{{$interface.Name}}(ctx context.Context, sel ast.Se {{- range $implementor := $interface.Implementors }} case {{$implementor.Type | ref}}: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"{{$interface.Type | typeName }}", "{{$implementor.Name}}"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } {{- if $implementor.CanBeNil }} if obj == nil { diff --git a/codegen/testserver/followschema/interfaces.generated.go b/codegen/testserver/followschema/interfaces.generated.go index 30ed6e8336d..0c1820feb57 100644 --- a/codegen/testserver/followschema/interfaces.generated.go +++ b/codegen/testserver/followschema/interfaces.generated.go @@ -1323,12 +1323,12 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return graphql.Null case Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Horse(ctx, sel, &obj) case *Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1336,12 +1336,12 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return ec._Horse(ctx, sel, obj) case Dog: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Dog"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Dog(ctx, sel, &obj) case *Dog: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Dog"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1349,12 +1349,12 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return ec._Dog(ctx, sel, obj) case Cat: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Cat"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Cat(ctx, sel, &obj) case *Cat: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Cat"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1362,7 +1362,7 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return ec._Cat(ctx, sel, obj) case Mammalian: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Mammalian"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1379,12 +1379,12 @@ func (ec *executionContext) _Mammalian(ctx context.Context, sel ast.SelectionSet return graphql.Null case Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Mammalian", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Horse(ctx, sel, &obj) case *Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Mammalian", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1401,7 +1401,7 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null case *ConcreteNodeA: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Node", "ConcreteNodeA"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1409,7 +1409,7 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return ec._ConcreteNodeA(ctx, sel, obj) case ConcreteNodeInterface: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Node", "ConcreteNodeInterface"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1426,7 +1426,7 @@ func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, ob return graphql.Null case *Circle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Shape", "Circle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1434,7 +1434,7 @@ func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, ob return ec._Circle(ctx, sel, obj) case *Rectangle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Shape", "Rectangle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1442,7 +1442,7 @@ func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, ob return ec._Rectangle(ctx, sel, obj) case *SquareShape: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Shape", "Square"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1459,7 +1459,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe return graphql.Null case *Circle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ShapeUnion", "Circle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1467,7 +1467,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe return ec._Circle(ctx, sel, obj) case *Rectangle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ShapeUnion", "Rectangle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1475,7 +1475,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe return ec._Rectangle(ctx, sel, obj) case *SquareShape: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ShapeUnion", "Square"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/codegen/testserver/followschema/useptr.generated.go b/codegen/testserver/followschema/useptr.generated.go index 30617119279..57fdd371dff 100644 --- a/codegen/testserver/followschema/useptr.generated.go +++ b/codegen/testserver/followschema/useptr.generated.go @@ -123,12 +123,12 @@ func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet return graphql.Null case A: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "A"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._A(ctx, sel, &obj) case *A: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "A"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -136,12 +136,12 @@ func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet return ec._A(ctx, sel, obj) case B: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "B"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._B(ctx, sel, &obj) case *B: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "B"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/codegen/testserver/followschema/validtypes.generated.go b/codegen/testserver/followschema/validtypes.generated.go index 9b516d2b8e3..d699a071dcb 100644 --- a/codegen/testserver/followschema/validtypes.generated.go +++ b/codegen/testserver/followschema/validtypes.generated.go @@ -1244,12 +1244,12 @@ func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.Selectio return graphql.Null case ContentUser: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Content_User(ctx, sel, &obj) case *ContentUser: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -1257,12 +1257,12 @@ func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.Selectio return ec._Content_User(ctx, sel, obj) case ContentPost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_Post"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Content_Post(ctx, sel, &obj) case *ContentPost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_Post"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/codegen/testserver/singlefile/generated.go b/codegen/testserver/singlefile/generated.go index c0806ddfef2..27aaff75740 100644 --- a/codegen/testserver/singlefile/generated.go +++ b/codegen/testserver/singlefile/generated.go @@ -17894,12 +17894,12 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return graphql.Null case Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Horse(ctx, sel, &obj) case *Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -17907,12 +17907,12 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return ec._Horse(ctx, sel, obj) case Dog: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Dog"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Dog(ctx, sel, &obj) case *Dog: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Dog"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -17920,12 +17920,12 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return ec._Dog(ctx, sel, obj) case Cat: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Cat"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Cat(ctx, sel, &obj) case *Cat: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Cat"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -17933,7 +17933,7 @@ func (ec *executionContext) _Animal(ctx context.Context, sel ast.SelectionSet, o return ec._Cat(ctx, sel, obj) case Mammalian: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Animal", "Mammalian"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -17950,12 +17950,12 @@ func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.Selectio return graphql.Null case ContentUser: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Content_User(ctx, sel, &obj) case *ContentUser: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_User"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -17963,12 +17963,12 @@ func (ec *executionContext) _Content_Child(ctx context.Context, sel ast.Selectio return ec._Content_User(ctx, sel, obj) case ContentPost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_Post"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Content_Post(ctx, sel, &obj) case *ContentPost: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ContentChild", "Content_Post"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -17985,12 +17985,12 @@ func (ec *executionContext) _Mammalian(ctx context.Context, sel ast.SelectionSet return graphql.Null case Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Mammalian", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Horse(ctx, sel, &obj) case *Horse: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Mammalian", "Horse"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18007,7 +18007,7 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return graphql.Null case *ConcreteNodeA: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Node", "ConcreteNodeA"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18015,7 +18015,7 @@ func (ec *executionContext) _Node(ctx context.Context, sel ast.SelectionSet, obj return ec._ConcreteNodeA(ctx, sel, obj) case ConcreteNodeInterface: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Node", "ConcreteNodeInterface"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18032,7 +18032,7 @@ func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, ob return graphql.Null case *Circle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Shape", "Circle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18040,7 +18040,7 @@ func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, ob return ec._Circle(ctx, sel, obj) case *Rectangle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Shape", "Rectangle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18048,7 +18048,7 @@ func (ec *executionContext) _Shape(ctx context.Context, sel ast.SelectionSet, ob return ec._Rectangle(ctx, sel, obj) case *SquareShape: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Shape", "Square"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18065,7 +18065,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe return graphql.Null case *Circle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ShapeUnion", "Circle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18073,7 +18073,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe return ec._Circle(ctx, sel, obj) case *Rectangle: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ShapeUnion", "Rectangle"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18081,7 +18081,7 @@ func (ec *executionContext) _ShapeUnion(ctx context.Context, sel ast.SelectionSe return ec._Rectangle(ctx, sel, obj) case *SquareShape: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"ShapeUnion", "Square"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18098,12 +18098,12 @@ func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet return graphql.Null case A: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "A"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._A(ctx, sel, &obj) case *A: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "A"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -18111,12 +18111,12 @@ func (ec *executionContext) _TestUnion(ctx context.Context, sel ast.SelectionSet return ec._A(ctx, sel, obj) case B: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "B"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._B(ctx, sel, &obj) case *B: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"TestUnion", "B"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/graphql/jsonw.go b/graphql/jsonw.go index 636476aaebd..ebd40e99473 100644 --- a/graphql/jsonw.go +++ b/graphql/jsonw.go @@ -18,9 +18,10 @@ var ( ) var ( - Null = &lit{nullLit} - True = &lit{trueLit} - False = &lit{falseLit} + Null = &lit{nullLit} + NullItem = &lit{nullLit} + True = &lit{trueLit} + False = &lit{falseLit} ) type Marshaler interface { @@ -74,7 +75,7 @@ func (a Array) MarshalGQL(writer io.Writer) { writer.Write(openBracket) var notEmpty bool for _, val := range a { - if _, ok := val.(Empty); ok { + if _, ok := val.(*lit); ok && val == NullItem { continue } if notEmpty { @@ -96,11 +97,3 @@ func (l lit) MarshalGQLContext(_ context.Context, w io.Writer) error { w.Write(l.b) return nil } - -type Empty struct{} - -func (e Empty) MarshalGQL(_ io.Writer) {} - -func (e Empty) MarshalGQLContext(_ context.Context, _ io.Writer) error { - return nil -} diff --git a/plugin/federation/testdata/computedrequires/generated/exec.go b/plugin/federation/testdata/computedrequires/generated/exec.go index 43700eeb125..cb1ff31f665 100644 --- a/plugin/federation/testdata/computedrequires/generated/exec.go +++ b/plugin/federation/testdata/computedrequires/generated/exec.go @@ -6165,12 +6165,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return graphql.Null case model.Hello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Hello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Hello(ctx, sel, &obj) case *model.Hello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Hello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6178,12 +6178,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._Hello(ctx, sel, obj) case model.HelloMultiSingleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloMultiSingleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._HelloMultiSingleKeys(ctx, sel, &obj) case *model.HelloMultiSingleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloMultiSingleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6191,12 +6191,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._HelloMultiSingleKeys(ctx, sel, obj) case model.HelloWithErrors: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloWithErrors"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._HelloWithErrors(ctx, sel, &obj) case *model.HelloWithErrors: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloWithErrors"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6204,12 +6204,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._HelloWithErrors(ctx, sel, obj) case model.MultiHello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHello(ctx, sel, &obj) case *model.MultiHello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6217,12 +6217,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHello(ctx, sel, obj) case model.MultiHelloMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloMultipleRequires(ctx, sel, &obj) case *model.MultiHelloMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6230,12 +6230,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloMultipleRequires(ctx, sel, obj) case model.MultiHelloRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloRequires(ctx, sel, &obj) case *model.MultiHelloRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6243,12 +6243,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloRequires(ctx, sel, obj) case model.MultiHelloWithError: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloWithError"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloWithError(ctx, sel, &obj) case *model.MultiHelloWithError: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloWithError"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6256,12 +6256,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloWithError(ctx, sel, obj) case model.MultiPlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiPlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiPlanetRequiresNested(ctx, sel, &obj) case *model.MultiPlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiPlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6269,12 +6269,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiPlanetRequiresNested(ctx, sel, obj) case model.PlanetMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetMultipleRequires(ctx, sel, &obj) case *model.PlanetMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6282,12 +6282,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetMultipleRequires(ctx, sel, obj) case model.PlanetRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetRequires(ctx, sel, &obj) case *model.PlanetRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6295,12 +6295,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetRequires(ctx, sel, obj) case model.PlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetRequiresNested(ctx, sel, &obj) case *model.PlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6308,12 +6308,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetRequiresNested(ctx, sel, obj) case model.World: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "World"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._World(ctx, sel, &obj) case *model.World: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "World"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6321,12 +6321,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._World(ctx, sel, obj) case model.WorldName: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldName"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._WorldName(ctx, sel, &obj) case *model.WorldName: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldName"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6334,12 +6334,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._WorldName(ctx, sel, obj) case model.WorldWithMultipleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldWithMultipleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._WorldWithMultipleKeys(ctx, sel, &obj) case *model.WorldWithMultipleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldWithMultipleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/plugin/federation/testdata/entityresolver/generated/exec.go b/plugin/federation/testdata/entityresolver/generated/exec.go index d65616d073b..2a2e381d3ff 100644 --- a/plugin/federation/testdata/entityresolver/generated/exec.go +++ b/plugin/federation/testdata/entityresolver/generated/exec.go @@ -6192,12 +6192,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return graphql.Null case model.Hello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Hello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Hello(ctx, sel, &obj) case *model.Hello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Hello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6205,12 +6205,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._Hello(ctx, sel, obj) case model.HelloMultiSingleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloMultiSingleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._HelloMultiSingleKeys(ctx, sel, &obj) case *model.HelloMultiSingleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloMultiSingleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6218,12 +6218,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._HelloMultiSingleKeys(ctx, sel, obj) case model.HelloWithErrors: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloWithErrors"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._HelloWithErrors(ctx, sel, &obj) case *model.HelloWithErrors: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloWithErrors"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6231,12 +6231,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._HelloWithErrors(ctx, sel, obj) case model.MultiHello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHello(ctx, sel, &obj) case *model.MultiHello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6244,12 +6244,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHello(ctx, sel, obj) case model.MultiHelloMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloMultipleRequires(ctx, sel, &obj) case *model.MultiHelloMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6257,12 +6257,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloMultipleRequires(ctx, sel, obj) case model.MultiHelloRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloRequires(ctx, sel, &obj) case *model.MultiHelloRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6270,12 +6270,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloRequires(ctx, sel, obj) case model.MultiHelloWithError: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloWithError"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloWithError(ctx, sel, &obj) case *model.MultiHelloWithError: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloWithError"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6283,12 +6283,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloWithError(ctx, sel, obj) case model.MultiPlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiPlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiPlanetRequiresNested(ctx, sel, &obj) case *model.MultiPlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiPlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6296,12 +6296,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiPlanetRequiresNested(ctx, sel, obj) case model.PlanetMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetMultipleRequires(ctx, sel, &obj) case *model.PlanetMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6309,12 +6309,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetMultipleRequires(ctx, sel, obj) case model.PlanetRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetRequires(ctx, sel, &obj) case *model.PlanetRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6322,12 +6322,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetRequires(ctx, sel, obj) case model.PlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetRequiresNested(ctx, sel, &obj) case *model.PlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6335,12 +6335,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetRequiresNested(ctx, sel, obj) case model.World: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "World"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._World(ctx, sel, &obj) case *model.World: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "World"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6348,12 +6348,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._World(ctx, sel, obj) case model.WorldName: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldName"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._WorldName(ctx, sel, &obj) case *model.WorldName: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldName"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -6361,12 +6361,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._WorldName(ctx, sel, obj) case model.WorldWithMultipleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldWithMultipleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._WorldWithMultipleKeys(ctx, sel, &obj) case *model.WorldWithMultipleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldWithMultipleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null diff --git a/plugin/federation/testdata/explicitrequires/generated/exec.go b/plugin/federation/testdata/explicitrequires/generated/exec.go index 099dd68a5e4..879fae3516d 100644 --- a/plugin/federation/testdata/explicitrequires/generated/exec.go +++ b/plugin/federation/testdata/explicitrequires/generated/exec.go @@ -5739,12 +5739,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return graphql.Null case Hello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Hello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._Hello(ctx, sel, &obj) case *Hello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "Hello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5752,12 +5752,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._Hello(ctx, sel, obj) case HelloMultiSingleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloMultiSingleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._HelloMultiSingleKeys(ctx, sel, &obj) case *HelloMultiSingleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloMultiSingleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5765,12 +5765,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._HelloMultiSingleKeys(ctx, sel, obj) case HelloWithErrors: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloWithErrors"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._HelloWithErrors(ctx, sel, &obj) case *HelloWithErrors: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "HelloWithErrors"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5778,12 +5778,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._HelloWithErrors(ctx, sel, obj) case MultiHello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHello(ctx, sel, &obj) case *MultiHello: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHello"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5791,12 +5791,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHello(ctx, sel, obj) case MultiHelloMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloMultipleRequires(ctx, sel, &obj) case *MultiHelloMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5804,12 +5804,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloMultipleRequires(ctx, sel, obj) case MultiHelloRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloRequires(ctx, sel, &obj) case *MultiHelloRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5817,12 +5817,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloRequires(ctx, sel, obj) case MultiHelloWithError: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloWithError"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiHelloWithError(ctx, sel, &obj) case *MultiHelloWithError: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiHelloWithError"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5830,12 +5830,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiHelloWithError(ctx, sel, obj) case MultiPlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiPlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._MultiPlanetRequiresNested(ctx, sel, &obj) case *MultiPlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "MultiPlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5843,12 +5843,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._MultiPlanetRequiresNested(ctx, sel, obj) case PlanetMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetMultipleRequires(ctx, sel, &obj) case *PlanetMultipleRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetMultipleRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5856,12 +5856,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetMultipleRequires(ctx, sel, obj) case PlanetRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetRequires(ctx, sel, &obj) case *PlanetRequires: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequires"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5869,12 +5869,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetRequires(ctx, sel, obj) case PlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._PlanetRequiresNested(ctx, sel, &obj) case *PlanetRequiresNested: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "PlanetRequiresNested"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5882,12 +5882,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._PlanetRequiresNested(ctx, sel, obj) case World: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "World"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._World(ctx, sel, &obj) case *World: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "World"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5895,12 +5895,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._World(ctx, sel, obj) case WorldName: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldName"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._WorldName(ctx, sel, &obj) case *WorldName: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldName"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null @@ -5908,12 +5908,12 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, return ec._WorldName(ctx, sel, obj) case WorldWithMultipleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldWithMultipleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } return ec._WorldWithMultipleKeys(ctx, sel, &obj) case *WorldWithMultipleKeys: if len(graphql.CollectFields(ec.OperationContext, sel, []string{"Entity", "WorldWithMultipleKeys"})) == 0 { - return graphql.Empty{} + return graphql.NullItem } if obj == nil { return graphql.Null