From fdd5b3234efa621c76c34a371beec7e17ef70177 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Mon, 27 Mar 2023 11:27:21 +1100 Subject: [PATCH 1/4] WIP --- plugin/federation/federation.go | 25 +- plugin/federation/federation.gotpl | 8 +- plugin/federation/federation_test.go | 10 + .../test_data/gqlmodels/federation.go | 22 + .../federatedentityresolver/generated/exec.go | 4296 +++++++++++++++++ .../generated/federation.go | 231 + .../federatedentityresolver/gqlgen.yml | 26 + .../gqlmodels/gqlmodels.go | 21 + .../resolvers/entity.resolvers.go | 28 + .../resolvers/resolver.go | 7 + .../resolvers/schema.resolvers.go | 23 + .../federatedentityresolver/schema.graphql | 34 + .../v2federation_entityresolver_test.go | 92 + 13 files changed, 4819 insertions(+), 4 deletions(-) create mode 100644 plugin/federation/test_data/gqlmodels/federation.go create mode 100644 plugin/federation/testdata/federatedentityresolver/generated/exec.go create mode 100644 plugin/federation/testdata/federatedentityresolver/generated/federation.go create mode 100644 plugin/federation/testdata/federatedentityresolver/gqlgen.yml create mode 100644 plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go create mode 100644 plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go create mode 100644 plugin/federation/testdata/federatedentityresolver/resolvers/resolver.go create mode 100644 plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go create mode 100644 plugin/federation/testdata/federatedentityresolver/schema.graphql create mode 100644 plugin/federation/v2federation_entityresolver_test.go diff --git a/plugin/federation/federation.go b/plugin/federation/federation.go index d0d3cac8a20..eccff66b8b5 100644 --- a/plugin/federation/federation.go +++ b/plugin/federation/federation.go @@ -11,6 +11,7 @@ import ( "github.com/99designs/gqlgen/codegen" "github.com/99designs/gqlgen/codegen/config" "github.com/99designs/gqlgen/codegen/templates" + "github.com/99designs/gqlgen/internal/rewrite" "github.com/99designs/gqlgen/plugin" "github.com/99designs/gqlgen/plugin/federation/fieldset" ) @@ -19,8 +20,21 @@ import ( var federationTemplate string type federation struct { - Entities []*Entity - Version int + Entities []*Entity + Version int + imports []rewrite.Import + ModelPackage string +} + +func (f *federation) Imports() string { + for _, imp := range f.imports { + if imp.Alias == "" { + _, _ = templates.CurrentImports.Reserve(imp.ImportPath) + } else { + _, _ = templates.CurrentImports.Reserve(imp.ImportPath, imp.Alias) + } + } + return "" } // New returns a federation plugin that injects @@ -199,6 +213,13 @@ type Entity { } func (f *federation) GenerateCode(data *codegen.Data) error { + if data.Config.Federation.Package != data.Config.Model.Package { + f.ModelPackage = fmt.Sprintf("%v.", data.Config.Model.Package) + f.imports = []rewrite.Import{ + {ImportPath: data.Config.Model.ImportPath(), + Alias: ""}, + } + } if len(f.Entities) > 0 { if data.Objects.ByName("Entity") != nil { data.Objects.ByName("Entity").Root = true diff --git a/plugin/federation/federation.gotpl b/plugin/federation/federation.gotpl index 4a30b6c9787..5f90af6969a 100644 --- a/plugin/federation/federation.gotpl +++ b/plugin/federation/federation.gotpl @@ -4,6 +4,8 @@ {{ reserveImport "strings" }} {{ reserveImport "sync" }} +{{ .Imports }} + {{ reserveImport "github.com/99designs/gqlgen/plugin/federation/fedruntime" }} var ( @@ -11,6 +13,8 @@ var ( ErrTypeNotFound = errors.New("type not found") ) +{{$out := .}} + func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { if ec.DisableIntrospection { return fedruntime.Service{}, errors.New("federated introspection disabled") @@ -133,7 +137,7 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati {{ if and .Resolvers .Multi -}} case "{{.Def.Name}}": {{range $i, $_ := .Resolvers -}} - _reps := make([]*{{.InputType}}, len(reps)) + _reps := make([]*{{$out.ModelPackage}}{{.InputType}}, len(reps)) for i, rep := range reps { {{ range $i, $keyField := .KeyFields -}} @@ -143,7 +147,7 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati } {{end}} - _reps[i] = &{{.InputType}} { + _reps[i] = &{{$out.ModelPackage}}{{.InputType}} { {{ range $i, $keyField := .KeyFields -}} {{$keyField.Field.ToGo}}: id{{$i}}, {{end}} diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index a0579f437d5..b3b71869e0e 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -116,6 +116,16 @@ func TestCodeGeneration(t *testing.T) { require.NoError(t, f.GenerateCode(data)) } +func TestCodeGenerationFederation2SplitDir(t *testing.T) { + f, cfg := load(t, "testdata/federatedentityresolver/gqlgen.yml") + err := f.MutateConfig(cfg) + require.NoError(t, err) + data, err := codegen.BuildData(cfg) + require.NoError(t, err) + err = f.GenerateCode(data) + require.NoError(t, err) +} + func TestCodeGenerationFederation2(t *testing.T) { f, cfg := load(t, "testdata/federation2/federation2.yml") err := f.MutateConfig(cfg) diff --git a/plugin/federation/test_data/gqlmodels/federation.go b/plugin/federation/test_data/gqlmodels/federation.go new file mode 100644 index 00000000000..98b47464803 --- /dev/null +++ b/plugin/federation/test_data/gqlmodels/federation.go @@ -0,0 +1,22 @@ +package model + +type _FieldSet string //nolint:deadcode,unused + +type Hello struct { + Name string + Secondary string +} + +func (Hello) IsEntity() {} + +type ExternalExtensionByUpcsInput struct { + Upc string +} + +func (ExternalExtensionByUpcsInput) IsEntity() {} + +type ExternalExtension struct { + Upc string +} + +func (ExternalExtension) IsEntity() {} diff --git a/plugin/federation/testdata/federatedentityresolver/generated/exec.go b/plugin/federation/testdata/federatedentityresolver/generated/exec.go new file mode 100644 index 00000000000..b2caba26fb5 --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/generated/exec.go @@ -0,0 +1,4296 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package generated + +import ( + "bytes" + "context" + "errors" + "fmt" + "strconv" + "sync" + + "github.com/99designs/gqlgen/graphql" + "github.com/99designs/gqlgen/graphql/introspection" + "github.com/99designs/gqlgen/plugin/federation/fedruntime" + "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" + gqlparser "github.com/vektah/gqlparser/v2" + "github.com/vektah/gqlparser/v2/ast" +) + +// region ************************** generated!.gotpl ************************** + +// NewExecutableSchema creates an ExecutableSchema from the ResolverRoot interface. +func NewExecutableSchema(cfg Config) graphql.ExecutableSchema { + return &executableSchema{ + resolvers: cfg.Resolvers, + directives: cfg.Directives, + complexity: cfg.Complexity, + } +} + +type Config struct { + Resolvers ResolverRoot + Directives DirectiveRoot + Complexity ComplexityRoot +} + +type ResolverRoot interface { + CustomQuery() CustomQueryResolver + Entity() EntityResolver +} + +type DirectiveRoot struct { + EntityResolver func(ctx context.Context, obj interface{}, next graphql.Resolver, multi *bool) (res interface{}, err error) +} + +type ComplexityRoot struct { + CustomQuery struct { + Hello func(childComplexity int) int + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + } + + Entity struct { + FindHelloByName func(childComplexity int, name string) int + FindManyExternalExtensionByUpcs func(childComplexity int, reps []gqlmodels.ExternalExtensionByUpcsInput) int + } + + ExternalExtension struct { + Reviews func(childComplexity int) int + Upc func(childComplexity int) int + } + + Hello struct { + Name func(childComplexity int) int + Secondary func(childComplexity int) int + } + + _Service struct { + SDL func(childComplexity int) int + } +} + +type CustomQueryResolver interface { + Hello(ctx context.Context) (*gqlmodels.Hello, error) +} +type EntityResolver interface { + FindManyExternalExtensionByUpcs(ctx context.Context, reps []gqlmodels.ExternalExtensionByUpcsInput) ([]*gqlmodels.ExternalExtension, error) + FindHelloByName(ctx context.Context, name string) (*gqlmodels.Hello, error) +} + +type executableSchema struct { + resolvers ResolverRoot + directives DirectiveRoot + complexity ComplexityRoot +} + +func (e *executableSchema) Schema() *ast.Schema { + return parsedSchema +} + +func (e *executableSchema) Complexity(typeName, field string, childComplexity int, rawArgs map[string]interface{}) (int, bool) { + ec := executionContext{nil, e} + _ = ec + switch typeName + "." + field { + + case "CustomQuery.hello": + if e.complexity.CustomQuery.Hello == nil { + break + } + + return e.complexity.CustomQuery.Hello(childComplexity), true + + case "CustomQuery._service": + if e.complexity.CustomQuery.__resolve__service == nil { + break + } + + return e.complexity.CustomQuery.__resolve__service(childComplexity), true + + case "CustomQuery._entities": + if e.complexity.CustomQuery.__resolve_entities == nil { + break + } + + args, err := ec.field_CustomQuery__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.CustomQuery.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true + + case "Entity.findHelloByName": + if e.complexity.Entity.FindHelloByName == nil { + break + } + + args, err := ec.field_Entity_findHelloByName_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindHelloByName(childComplexity, args["name"].(string)), true + + case "Entity.findManyExternalExtensionByUpcs": + if e.complexity.Entity.FindManyExternalExtensionByUpcs == nil { + break + } + + args, err := ec.field_Entity_findManyExternalExtensionByUpcs_args(context.TODO(), rawArgs) + if err != nil { + return 0, false + } + + return e.complexity.Entity.FindManyExternalExtensionByUpcs(childComplexity, args["reps"].([]gqlmodels.ExternalExtensionByUpcsInput)), true + + case "ExternalExtension.reviews": + if e.complexity.ExternalExtension.Reviews == nil { + break + } + + return e.complexity.ExternalExtension.Reviews(childComplexity), true + + case "ExternalExtension.upc": + if e.complexity.ExternalExtension.Upc == nil { + break + } + + return e.complexity.ExternalExtension.Upc(childComplexity), true + + case "Hello.name": + if e.complexity.Hello.Name == nil { + break + } + + return e.complexity.Hello.Name(childComplexity), true + + case "Hello.secondary": + if e.complexity.Hello.Secondary == nil { + break + } + + return e.complexity.Hello.Secondary(childComplexity), true + + case "_Service.sdl": + if e.complexity._Service.SDL == nil { + break + } + + return e.complexity._Service.SDL(childComplexity), true + + } + return 0, false +} + +func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { + rc := graphql.GetOperationContext(ctx) + ec := executionContext{rc, e} + inputUnmarshalMap := graphql.BuildUnmarshalerMap( + ec.unmarshalInputExternalExtensionByUpcsInput, + ) + first := true + + switch rc.Operation.Operation { + case ast.Query: + return func(ctx context.Context) *graphql.Response { + if !first { + return nil + } + first = false + ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) + data := ec._CustomQuery(ctx, rc.Operation.SelectionSet) + var buf bytes.Buffer + data.MarshalGQL(&buf) + + return &graphql.Response{ + Data: buf.Bytes(), + } + } + + default: + return graphql.OneShot(graphql.ErrorResponse(ctx, "unsupported GraphQL operation")) + } +} + +type executionContext struct { + *graphql.OperationContext + *executableSchema +} + +func (ec *executionContext) introspectSchema() (*introspection.Schema, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapSchema(parsedSchema), nil +} + +func (ec *executionContext) introspectType(name string) (*introspection.Type, error) { + if ec.DisableIntrospection { + return nil, errors.New("introspection disabled") + } + return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil +} + +var sources = []*ast.Source{ + {Name: "../schema.graphql", Input: `extend schema + @link( + url: "https://specs.apollo.dev/federation/v2.0" + import: [ + "@key" + "@shareable" + "@provides" + "@external" + "@tag" + "@extends" + "@override" + "@inaccessible" + ] + ) + +schema { + query: CustomQuery +} + +directive @entityResolver(multi: Boolean) on OBJECT + +type Hello @key(fields: "name") { + name: String! + secondary: String! +} + +extend type ExternalExtension @key(fields: "upc") @entityResolver(multi: true) { + upc: String! + reviews: [Hello] +} + +type CustomQuery { + hello: Hello +} +`, BuiltIn: false}, + {Name: "../../../federation/directives.graphql", Input: ` + scalar _Any + scalar _FieldSet + + directive @external on FIELD_DEFINITION + directive @requires(fields: _FieldSet!) on FIELD_DEFINITION + directive @provides(fields: _FieldSet!) on FIELD_DEFINITION + directive @extends on OBJECT | INTERFACE + + directive @key(fields: _FieldSet!, resolvable: Boolean = true) repeatable on OBJECT | INTERFACE + directive @link(import: [String!], url: String!) repeatable on SCHEMA + directive @shareable on OBJECT | FIELD_DEFINITION + directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION + directive @override(from: String!) on FIELD_DEFINITION + directive @inaccessible on SCALAR | OBJECT | FIELD_DEFINITION | ARGUMENT_DEFINITION | INTERFACE | UNION | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION +`, BuiltIn: true}, + {Name: "../../../federation/entity.graphql", Input: ` +# a union of all types that use the @key directive +union _Entity = ExternalExtension | Hello + +input ExternalExtensionByUpcsInput { + Upc: String! +} + +# fake type to build resolver interfaces for users to implement +type Entity { + findManyExternalExtensionByUpcs(reps: [ExternalExtensionByUpcsInput!]!): [ExternalExtension] + findHelloByName(name: String!,): Hello! + +} + +type _Service { + sdl: String +} + +extend type CustomQuery { + _entities(representations: [_Any!]!): [_Entity]! + _service: _Service! +} +`, BuiltIn: true}, +} +var parsedSchema = gqlparser.MustLoadSchema(sources...) + +// endregion ************************** generated!.gotpl ************************** + +// region ***************************** args.gotpl ***************************** + +func (ec *executionContext) dir_entityResolver_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 *bool + if tmp, ok := rawArgs["multi"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("multi")) + arg0, err = ec.unmarshalOBoolean2ᚖbool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["multi"] = arg0 + return args, nil +} + +func (ec *executionContext) field_CustomQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (ec *executionContext) field_CustomQuery__entities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []map[string]interface{} + if tmp, ok := rawArgs["representations"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("representations")) + arg0, err = ec.unmarshalN_Any2ᚕmapᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["representations"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findHelloByName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 string + if tmp, ok := rawArgs["name"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) + arg0, err = ec.unmarshalNString2string(ctx, tmp) + if err != nil { + return nil, err + } + } + args["name"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Entity_findManyExternalExtensionByUpcs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []gqlmodels.ExternalExtensionByUpcsInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNExternalExtensionByUpcsInput2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInputᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_enumValues_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 bool + if tmp, ok := rawArgs["includeDeprecated"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("includeDeprecated")) + arg0, err = ec.unmarshalOBoolean2bool(ctx, tmp) + if err != nil { + return nil, err + } + } + args["includeDeprecated"] = arg0 + return args, nil +} + +// endregion ***************************** args.gotpl ***************************** + +// region ************************** directives.gotpl ************************** + +// endregion ************************** directives.gotpl ************************** + +// region **************************** field.gotpl ***************************** + +func (ec *executionContext) _CustomQuery_hello(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CustomQuery_hello(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.CustomQuery().Hello(rctx) + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*gqlmodels.Hello) + fc.Result = res + return ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CustomQuery_hello(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CustomQuery", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Hello_name(ctx, field) + case "secondary": + return ec.fieldContext_Hello_secondary(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CustomQuery__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CustomQuery__entities(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]interface{})), nil + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]fedruntime.Entity) + fc.Result = res + return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CustomQuery__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CustomQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type _Entity does not have child fields") + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_CustomQuery__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _CustomQuery__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CustomQuery__service(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.__resolve__service(ctx) + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(fedruntime.Service) + fc.Result = res + return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CustomQuery__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CustomQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _CustomQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CustomQuery___type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectType(fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CustomQuery___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CustomQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_CustomQuery___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _CustomQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_CustomQuery___schema(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.introspectSchema() + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Schema) + fc.Result = res + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_CustomQuery___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "CustomQuery", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Entity_findManyExternalExtensionByUpcs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyExternalExtensionByUpcs(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyExternalExtensionByUpcs(rctx, fc.Args["reps"].([]gqlmodels.ExternalExtensionByUpcsInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*gqlmodels.ExternalExtension); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels.ExternalExtension`, tmp) + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*gqlmodels.ExternalExtension) + fc.Result = res + return ec.marshalOExternalExtension2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findManyExternalExtensionByUpcs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "upc": + return ec.fieldContext_ExternalExtension_upc(ctx, field) + case "reviews": + return ec.fieldContext_ExternalExtension_reviews(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type ExternalExtension", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findManyExternalExtensionByUpcs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _Entity_findHelloByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findHelloByName(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindHelloByName(rctx, fc.Args["name"].(string)) + }) + if err != nil { + ec.Error(ctx, err) + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*gqlmodels.Hello) + fc.Result = res + return ec.marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Entity_findHelloByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Entity", + Field: field, + IsMethod: true, + IsResolver: true, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Hello_name(ctx, field) + case "secondary": + return ec.fieldContext_Hello_secondary(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Entity_findHelloByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) _ExternalExtension_upc(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.ExternalExtension) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ExternalExtension_upc(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Upc, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ExternalExtension_upc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ExternalExtension", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _ExternalExtension_reviews(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.ExternalExtension) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_ExternalExtension_reviews(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Reviews, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]*gqlmodels.Hello) + fc.Result = res + return ec.marshalOHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_ExternalExtension_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "ExternalExtension", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext_Hello_name(ctx, field) + case "secondary": + return ec.fieldContext_Hello_secondary(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) _Hello_name(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.Hello) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Hello_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Hello_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Hello", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) _Hello_secondary(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.Hello) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Hello_secondary(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Secondary, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext_Hello_secondary(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "Hello", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) __Service_sdl(ctx context.Context, field graphql.CollectedField, obj *fedruntime.Service) (ret graphql.Marshaler) { + fc, err := ec.fieldContext__Service_sdl(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SDL, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalOString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext__Service_sdl(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "_Service", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_locations(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_locations(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Locations, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]string) + fc.Result = res + return ec.marshalN__DirectiveLocation2ᚕstringᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_locations(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __DirectiveLocation does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField, obj *introspection.Directive) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Directive_isRepeatable(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsRepeatable, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Directive_isRepeatable(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Directive", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.EnumValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___EnumValue_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___EnumValue_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__EnumValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_args(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_args(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Args, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_args(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_type(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_isDeprecated(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_isDeprecated(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.IsDeprecated(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(bool) + fc.Result = res + return ec.marshalNBoolean2bool(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_isDeprecated(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type Boolean does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Field_deprecationReason(ctx context.Context, field graphql.CollectedField, obj *introspection.Field) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Field_deprecationReason(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DeprecationReason(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Field_deprecationReason(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Field", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_name(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalNString2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_description(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_type(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_type(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Type, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField, obj *introspection.InputValue) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___InputValue_defaultValue(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.DefaultValue, nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___InputValue_defaultValue(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__InputValue", + Field: field, + IsMethod: false, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_types(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_types(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Types(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_types(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_queryType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_queryType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.QueryType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_queryType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_mutationType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_mutationType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.MutationType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_mutationType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_subscriptionType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SubscriptionType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_subscriptionType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Schema_directives(ctx context.Context, field graphql.CollectedField, obj *introspection.Schema) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Schema_directives(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Directives(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.([]introspection.Directive) + fc.Result = res + return ec.marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Schema_directives(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Schema", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Directive_name(ctx, field) + case "description": + return ec.fieldContext___Directive_description(ctx, field) + case "locations": + return ec.fieldContext___Directive_locations(ctx, field) + case "args": + return ec.fieldContext___Directive_args(ctx, field) + case "isRepeatable": + return ec.fieldContext___Directive_isRepeatable(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Directive", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_kind(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_kind(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Kind(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + if !graphql.HasFieldError(ctx, fc) { + ec.Errorf(ctx, "must not be null") + } + return graphql.Null + } + res := resTmp.(string) + fc.Result = res + return ec.marshalN__TypeKind2string(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_kind(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type __TypeKind does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_name(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_name(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Name(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_description(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_description(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Description(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_description(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_fields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_fields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Fields(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Field) + fc.Result = res + return ec.marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_fields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___Field_name(ctx, field) + case "description": + return ec.fieldContext___Field_description(ctx, field) + case "args": + return ec.fieldContext___Field_args(ctx, field) + case "type": + return ec.fieldContext___Field_type(ctx, field) + case "isDeprecated": + return ec.fieldContext___Field_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___Field_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Field", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_fields_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Type_interfaces(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_interfaces(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.Interfaces(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_interfaces(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_possibleTypes(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_possibleTypes(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.PossibleTypes(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_possibleTypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_enumValues(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_enumValues(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.EnumValues(fc.Args["includeDeprecated"].(bool)), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.EnumValue) + fc.Result = res + return ec.marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_enumValues(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___EnumValue_name(ctx, field) + case "description": + return ec.fieldContext___EnumValue_description(ctx, field) + case "isDeprecated": + return ec.fieldContext___EnumValue_isDeprecated(ctx, field) + case "deprecationReason": + return ec.fieldContext___EnumValue_deprecationReason(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __EnumValue", field.Name) + }, + } + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + ec.Error(ctx, err) + } + }() + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field___Type_enumValues_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + ec.Error(ctx, err) + return + } + return fc, nil +} + +func (ec *executionContext) ___Type_inputFields(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_inputFields(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.InputFields(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.([]introspection.InputValue) + fc.Result = res + return ec.marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_inputFields(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "name": + return ec.fieldContext___InputValue_name(ctx, field) + case "description": + return ec.fieldContext___InputValue_description(ctx, field) + case "type": + return ec.fieldContext___InputValue_type(ctx, field) + case "defaultValue": + return ec.fieldContext___InputValue_defaultValue(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __InputValue", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_ofType(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_ofType(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.OfType(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*introspection.Type) + fc.Result = res + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_ofType(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) + case "name": + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + }, + } + return fc, nil +} + +func (ec *executionContext) ___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField, obj *introspection.Type) (ret graphql.Marshaler) { + fc, err := ec.fieldContext___Type_specifiedByURL(ctx, field) + if err != nil { + return graphql.Null + } + ctx = graphql.WithFieldContext(ctx, fc) + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + ret = graphql.Null + } + }() + resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return obj.SpecifiedByURL(), nil + }) + if err != nil { + ec.Error(ctx, err) + return graphql.Null + } + if resTmp == nil { + return graphql.Null + } + res := resTmp.(*string) + fc.Result = res + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) +} + +func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { + fc = &graphql.FieldContext{ + Object: "__Type", + Field: field, + IsMethod: true, + IsResolver: false, + Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { + return nil, errors.New("field of type String does not have child fields") + }, + } + return fc, nil +} + +// endregion **************************** field.gotpl ***************************** + +// region **************************** input.gotpl ***************************** + +func (ec *executionContext) unmarshalInputExternalExtensionByUpcsInput(ctx context.Context, obj interface{}) (gqlmodels.ExternalExtensionByUpcsInput, error) { + var it gqlmodels.ExternalExtensionByUpcsInput + asMap := map[string]interface{}{} + for k, v := range obj.(map[string]interface{}) { + asMap[k] = v + } + + fieldsInOrder := [...]string{"Upc"} + for _, k := range fieldsInOrder { + v, ok := asMap[k] + if !ok { + continue + } + switch k { + case "Upc": + var err error + + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Upc")) + it.Upc, err = ec.unmarshalNString2string(ctx, v) + if err != nil { + return it, err + } + } + } + + return it, nil +} + +// endregion **************************** input.gotpl ***************************** + +// region ************************** interface.gotpl *************************** + +func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { + switch obj := (obj).(type) { + case nil: + return graphql.Null + case gqlmodels.ExternalExtension: + return ec._ExternalExtension(ctx, sel, &obj) + case *gqlmodels.ExternalExtension: + if obj == nil { + return graphql.Null + } + return ec._ExternalExtension(ctx, sel, obj) + case gqlmodels.Hello: + return ec._Hello(ctx, sel, &obj) + case *gqlmodels.Hello: + if obj == nil { + return graphql.Null + } + return ec._Hello(ctx, sel, obj) + default: + panic(fmt.Errorf("unexpected type %T", obj)) + } +} + +// endregion ************************** interface.gotpl *************************** + +// region **************************** object.gotpl **************************** + +var customQueryImplementors = []string{"CustomQuery"} + +func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, customQueryImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "CustomQuery", + }) + + out := graphql.NewFieldSet(fields) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("CustomQuery") + case "hello": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._CustomQuery_hello(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } + + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + case "_entities": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._CustomQuery__entities(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } + + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + case "_service": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._CustomQuery__service(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } + + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + case "__type": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._CustomQuery___type(ctx, field) + }) + + case "__schema": + + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._CustomQuery___schema(ctx, field) + }) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + return out +} + +var entityImplementors = []string{"Entity"} + +func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) + ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ + Object: "Entity", + }) + + out := graphql.NewFieldSet(fields) + for i, field := range fields { + innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ + Object: field.Name, + Field: field, + }) + + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Entity") + case "findManyExternalExtensionByUpcs": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findManyExternalExtensionByUpcs(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } + + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + case "findHelloByName": + field := field + + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Entity_findHelloByName(ctx, field) + return res + } + + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } + + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + return out +} + +var externalExtensionImplementors = []string{"ExternalExtension", "_Entity"} + +func (ec *executionContext) _ExternalExtension(ctx context.Context, sel ast.SelectionSet, obj *gqlmodels.ExternalExtension) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, externalExtensionImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("ExternalExtension") + case "upc": + + out.Values[i] = ec._ExternalExtension_upc(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "reviews": + + out.Values[i] = ec._ExternalExtension_reviews(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var helloImplementors = []string{"Hello", "_Entity"} + +func (ec *executionContext) _Hello(ctx context.Context, sel ast.SelectionSet, obj *gqlmodels.Hello) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, helloImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Hello") + case "name": + + out.Values[i] = ec._Hello_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "secondary": + + out.Values[i] = ec._Hello_secondary(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var _ServiceImplementors = []string{"_Service"} + +func (ec *executionContext) __Service(ctx context.Context, sel ast.SelectionSet, obj *fedruntime.Service) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, _ServiceImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("_Service") + case "sdl": + + out.Values[i] = ec.__Service_sdl(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var __DirectiveImplementors = []string{"__Directive"} + +func (ec *executionContext) ___Directive(ctx context.Context, sel ast.SelectionSet, obj *introspection.Directive) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __DirectiveImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Directive") + case "name": + + out.Values[i] = ec.___Directive_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___Directive_description(ctx, field, obj) + + case "locations": + + out.Values[i] = ec.___Directive_locations(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "args": + + out.Values[i] = ec.___Directive_args(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "isRepeatable": + + out.Values[i] = ec.___Directive_isRepeatable(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var __EnumValueImplementors = []string{"__EnumValue"} + +func (ec *executionContext) ___EnumValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.EnumValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __EnumValueImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__EnumValue") + case "name": + + out.Values[i] = ec.___EnumValue_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___EnumValue_description(ctx, field, obj) + + case "isDeprecated": + + out.Values[i] = ec.___EnumValue_isDeprecated(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "deprecationReason": + + out.Values[i] = ec.___EnumValue_deprecationReason(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var __FieldImplementors = []string{"__Field"} + +func (ec *executionContext) ___Field(ctx context.Context, sel ast.SelectionSet, obj *introspection.Field) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __FieldImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Field") + case "name": + + out.Values[i] = ec.___Field_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___Field_description(ctx, field, obj) + + case "args": + + out.Values[i] = ec.___Field_args(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "type": + + out.Values[i] = ec.___Field_type(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "isDeprecated": + + out.Values[i] = ec.___Field_isDeprecated(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "deprecationReason": + + out.Values[i] = ec.___Field_deprecationReason(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var __InputValueImplementors = []string{"__InputValue"} + +func (ec *executionContext) ___InputValue(ctx context.Context, sel ast.SelectionSet, obj *introspection.InputValue) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __InputValueImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__InputValue") + case "name": + + out.Values[i] = ec.___InputValue_name(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "description": + + out.Values[i] = ec.___InputValue_description(ctx, field, obj) + + case "type": + + out.Values[i] = ec.___InputValue_type(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "defaultValue": + + out.Values[i] = ec.___InputValue_defaultValue(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var __SchemaImplementors = []string{"__Schema"} + +func (ec *executionContext) ___Schema(ctx context.Context, sel ast.SelectionSet, obj *introspection.Schema) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __SchemaImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Schema") + case "description": + + out.Values[i] = ec.___Schema_description(ctx, field, obj) + + case "types": + + out.Values[i] = ec.___Schema_types(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "queryType": + + out.Values[i] = ec.___Schema_queryType(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "mutationType": + + out.Values[i] = ec.___Schema_mutationType(ctx, field, obj) + + case "subscriptionType": + + out.Values[i] = ec.___Schema_subscriptionType(ctx, field, obj) + + case "directives": + + out.Values[i] = ec.___Schema_directives(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var __TypeImplementors = []string{"__Type"} + +func (ec *executionContext) ___Type(ctx context.Context, sel ast.SelectionSet, obj *introspection.Type) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, __TypeImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("__Type") + case "kind": + + out.Values[i] = ec.___Type_kind(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "name": + + out.Values[i] = ec.___Type_name(ctx, field, obj) + + case "description": + + out.Values[i] = ec.___Type_description(ctx, field, obj) + + case "fields": + + out.Values[i] = ec.___Type_fields(ctx, field, obj) + + case "interfaces": + + out.Values[i] = ec.___Type_interfaces(ctx, field, obj) + + case "possibleTypes": + + out.Values[i] = ec.___Type_possibleTypes(ctx, field, obj) + + case "enumValues": + + out.Values[i] = ec.___Type_enumValues(ctx, field, obj) + + case "inputFields": + + out.Values[i] = ec.___Type_inputFields(ctx, field, obj) + + case "ofType": + + out.Values[i] = ec.___Type_ofType(ctx, field, obj) + + case "specifiedByURL": + + out.Values[i] = ec.___Type_specifiedByURL(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +// endregion **************************** object.gotpl **************************** + +// region ***************************** type.gotpl ***************************** + +func (ec *executionContext) unmarshalNBoolean2bool(ctx context.Context, v interface{}) (bool, error) { + res, err := graphql.UnmarshalBoolean(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + res := graphql.MarshalBoolean(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalNExternalExtensionByUpcsInput2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInput(ctx context.Context, v interface{}) (gqlmodels.ExternalExtensionByUpcsInput, error) { + res, err := ec.unmarshalInputExternalExtensionByUpcsInput(ctx, v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) unmarshalNExternalExtensionByUpcsInput2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInputᚄ(ctx context.Context, v interface{}) ([]gqlmodels.ExternalExtensionByUpcsInput, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]gqlmodels.ExternalExtensionByUpcsInput, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNExternalExtensionByUpcsInput2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInput(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNHello2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v gqlmodels.Hello) graphql.Marshaler { + return ec._Hello(ctx, sel, &v) +} + +func (ec *executionContext) marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.Hello) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec._Hello(ctx, sel, v) +} + +func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2map(ctx context.Context, v interface{}) (map[string]interface{}, error) { + res, err := graphql.UnmarshalMap(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_Any2map(ctx context.Context, sel ast.SelectionSet, v map[string]interface{}) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + res := graphql.MarshalMap(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN_Any2ᚕmapᚄ(ctx context.Context, v interface{}) ([]map[string]interface{}, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]map[string]interface{}, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN_Any2map(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN_Any2ᚕmapᚄ(ctx context.Context, sel ast.SelectionSet, v []map[string]interface{}) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalN_Any2map(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v []fedruntime.Entity) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx context.Context, sel ast.SelectionSet, v fedruntime.Service) graphql.Marshaler { + return ec.__Service(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx context.Context, sel ast.SelectionSet, v introspection.Directive) graphql.Marshaler { + return ec.___Directive(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Directive2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirectiveᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Directive) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Directive2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐDirective(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__DirectiveLocation2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalN__DirectiveLocation2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalN__DirectiveLocation2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__DirectiveLocation2string(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx context.Context, sel ast.SelectionSet, v introspection.EnumValue) graphql.Marshaler { + return ec.___EnumValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx context.Context, sel ast.SelectionSet, v introspection.Field) graphql.Marshaler { + return ec.___Field(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx context.Context, sel ast.SelectionSet, v introspection.InputValue) graphql.Marshaler { + return ec.___InputValue(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v introspection.Type) graphql.Marshaler { + return ec.___Type(ctx, sel, &v) +} + +func (ec *executionContext) marshalN__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalN__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +func (ec *executionContext) unmarshalN__TypeKind2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalN__TypeKind2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { + if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { + ec.Errorf(ctx, "the requested element is null which the schema does not allow") + } + } + return res +} + +func (ec *executionContext) unmarshalOBoolean2bool(ctx context.Context, v interface{}) (bool, error) { + res, err := graphql.UnmarshalBoolean(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBoolean2bool(ctx context.Context, sel ast.SelectionSet, v bool) graphql.Marshaler { + res := graphql.MarshalBoolean(v) + return res +} + +func (ec *executionContext) unmarshalOBoolean2ᚖbool(ctx context.Context, v interface{}) (*bool, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalBoolean(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast.SelectionSet, v *bool) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalBoolean(*v) + return res +} + +func (ec *executionContext) marshalOExternalExtension2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx context.Context, sel ast.SelectionSet, v []*gqlmodels.ExternalExtension) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOExternalExtension2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOExternalExtension2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.ExternalExtension) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._ExternalExtension(ctx, sel, v) +} + +func (ec *executionContext) marshalOHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v []*gqlmodels.Hello) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + return ret +} + +func (ec *executionContext) marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.Hello) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec._Hello(ctx, sel, v) +} + +func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOString2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + return res +} + +func (ec *executionContext) unmarshalOString2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + if v == nil { + return nil, nil + } + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNString2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalOString2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNString2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) unmarshalOString2ᚖstring(ctx context.Context, v interface{}) (*string, error) { + if v == nil { + return nil, nil + } + res, err := graphql.UnmarshalString(v) + return &res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalOString2ᚖstring(ctx context.Context, sel ast.SelectionSet, v *string) graphql.Marshaler { + if v == nil { + return graphql.Null + } + res := graphql.MarshalString(*v) + return res +} + +func (ec *executionContext) marshalO_Entity2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx context.Context, sel ast.SelectionSet, v fedruntime.Entity) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.__Entity(ctx, sel, v) +} + +func (ec *executionContext) marshalO__EnumValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.EnumValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__EnumValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐEnumValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__Field2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐFieldᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Field) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Field2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐField(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__InputValue2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValueᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.InputValue) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__InputValue2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐInputValue(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx context.Context, sel ast.SelectionSet, v *introspection.Schema) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Schema(ctx, sel, v) +} + +func (ec *executionContext) marshalO__Type2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐTypeᚄ(ctx context.Context, sel ast.SelectionSet, v []introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + ret := make(graphql.Array, len(v)) + var wg sync.WaitGroup + isLen1 := len(v) == 1 + if !isLen1 { + wg.Add(len(v)) + } + for i := range v { + i := i + fc := &graphql.FieldContext{ + Index: &i, + Result: &v[i], + } + 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 !isLen1 { + defer wg.Done() + } + ret[i] = ec.marshalN__Type2githubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, sel, v[i]) + } + if isLen1 { + f(i) + } else { + go f(i) + } + + } + wg.Wait() + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret +} + +func (ec *executionContext) marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx context.Context, sel ast.SelectionSet, v *introspection.Type) graphql.Marshaler { + if v == nil { + return graphql.Null + } + return ec.___Type(ctx, sel, v) +} + +// endregion ***************************** type.gotpl ***************************** diff --git a/plugin/federation/testdata/federatedentityresolver/generated/federation.go b/plugin/federation/testdata/federatedentityresolver/generated/federation.go new file mode 100644 index 00000000000..4a3867be6ea --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/generated/federation.go @@ -0,0 +1,231 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package generated + +import ( + "context" + "errors" + "fmt" + "strings" + "sync" + + "github.com/99designs/gqlgen/plugin/federation/fedruntime" + "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" +) + +var ( + ErrUnknownType = errors.New("unknown type") + ErrTypeNotFound = errors.New("type not found") +) + +func (ec *executionContext) __resolve__service(ctx context.Context) (fedruntime.Service, error) { + if ec.DisableIntrospection { + return fedruntime.Service{}, errors.New("federated introspection disabled") + } + + var sdl []string + + for _, src := range sources { + if src.BuiltIn { + continue + } + sdl = append(sdl, src.Input) + } + + return fedruntime.Service{ + SDL: strings.Join(sdl, "\n"), + }, nil +} + +func (ec *executionContext) __resolve_entities(ctx context.Context, representations []map[string]interface{}) []fedruntime.Entity { + list := make([]fedruntime.Entity, len(representations)) + + repsMap := map[string]struct { + i []int + r []map[string]interface{} + }{} + + // We group entities by typename so that we can parallelize their resolution. + // This is particularly helpful when there are entity groups in multi mode. + buildRepresentationGroups := func(reps []map[string]interface{}) { + for i, rep := range reps { + typeName, ok := rep["__typename"].(string) + if !ok { + // If there is no __typename, we just skip the representation; + // we just won't be resolving these unknown types. + ec.Error(ctx, errors.New("__typename must be an existing string")) + continue + } + + _r := repsMap[typeName] + _r.i = append(_r.i, i) + _r.r = append(_r.r, rep) + repsMap[typeName] = _r + } + } + + isMulti := func(typeName string) bool { + switch typeName { + case "ExternalExtension": + return true + default: + return false + } + } + + resolveEntity := func(ctx context.Context, typeName string, rep map[string]interface{}, idx []int, i int) (err error) { + // we need to do our own panic handling, because we may be called in a + // goroutine, where the usual panic handling can't catch us + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + } + }() + + switch typeName { + case "Hello": + resolverName, err := entityResolverNameForHello(ctx, rep) + if err != nil { + return fmt.Errorf(`finding resolver for Entity "Hello": %w`, err) + } + switch resolverName { + + case "findHelloByName": + id0, err := ec.unmarshalNString2string(ctx, rep["name"]) + if err != nil { + return fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err) + } + entity, err := ec.resolvers.Entity().FindHelloByName(ctx, id0) + if err != nil { + return fmt.Errorf(`resolving Entity "Hello": %w`, err) + } + + list[idx[i]] = entity + return nil + } + + } + return fmt.Errorf("%w: %s", ErrUnknownType, typeName) + } + + resolveManyEntities := func(ctx context.Context, typeName string, reps []map[string]interface{}, idx []int) (err error) { + // we need to do our own panic handling, because we may be called in a + // goroutine, where the usual panic handling can't catch us + defer func() { + if r := recover(); r != nil { + err = ec.Recover(ctx, r) + } + }() + + switch typeName { + + case "ExternalExtension": + _reps := make([]*gqlmodels.ExternalExtensionByUpcsInput, len(reps)) + + for i, rep := range reps { + id0, err := ec.unmarshalNString2string(ctx, rep["upc"]) + if err != nil { + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "upc")) + } + + _reps[i] = &gqlmodels.ExternalExtensionByUpcsInput{ + Upc: id0, + } + } + + entities, err := ec.resolvers.Entity().FindManyExternalExtensionByUpcs(ctx, _reps) + if err != nil { + return err + } + + for i, entity := range entities { + list[idx[i]] = entity + } + return nil + + default: + return errors.New("unknown type: " + typeName) + } + } + + resolveEntityGroup := func(typeName string, reps []map[string]interface{}, idx []int) { + if isMulti(typeName) { + err := resolveManyEntities(ctx, typeName, reps, idx) + if err != nil { + ec.Error(ctx, err) + } + } else { + // if there are multiple entities to resolve, parallelize (similar to + // graphql.FieldSet.Dispatch) + var e sync.WaitGroup + e.Add(len(reps)) + for i, rep := range reps { + i, rep := i, rep + go func(i int, rep map[string]interface{}) { + err := resolveEntity(ctx, typeName, rep, idx, i) + if err != nil { + ec.Error(ctx, err) + } + e.Done() + }(i, rep) + } + e.Wait() + } + } + buildRepresentationGroups(representations) + + switch len(repsMap) { + case 0: + return list + case 1: + for typeName, reps := range repsMap { + resolveEntityGroup(typeName, reps.r, reps.i) + } + return list + default: + var g sync.WaitGroup + g.Add(len(repsMap)) + for typeName, reps := range repsMap { + go func(typeName string, reps []map[string]interface{}, idx []int) { + resolveEntityGroup(typeName, reps, idx) + g.Done() + }(typeName, reps.r, reps.i) + } + g.Wait() + return list + } +} + +func entityResolverNameForExternalExtension(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["upc"]; !ok { + break + } + return "findManyExternalExtensionByUpcs", nil + } + return "", fmt.Errorf("%w for ExternalExtension", ErrTypeNotFound) +} + +func entityResolverNameForHello(ctx context.Context, rep map[string]interface{}) (string, error) { + for { + var ( + m map[string]interface{} + val interface{} + ok bool + ) + _ = val + m = rep + if _, ok = m["name"]; !ok { + break + } + return "findHelloByName", nil + } + return "", fmt.Errorf("%w for Hello", ErrTypeNotFound) +} diff --git a/plugin/federation/testdata/federatedentityresolver/gqlgen.yml b/plugin/federation/testdata/federatedentityresolver/gqlgen.yml new file mode 100644 index 00000000000..f63bb8336e1 --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/gqlgen.yml @@ -0,0 +1,26 @@ +schema: + - "testdata/federatedentityresolver/schema.graphql" +exec: + filename: testdata/federatedentityresolver/generated/exec.go + package: generated +federation: + filename: testdata/federatedentityresolver/generated/federation.go + package: generated + version: 2 +model: + filename: testdata/federatedentityresolver/gqlmodels/gqlmodels.go + package: gqlmodels +resolver: + layout: follow-schema + dir: testdata/federatedentityresolver/resolvers + package: resolvers + filename_template: "{name}.resolvers.go" + +omit_slice_element_pointers: true + +models: + ID: + model: + - github.com/99designs/gqlgen/graphql.String + - github.com/99designs/gqlgen/graphql.Int + - github.com/99designs/gqlgen/graphql.ID diff --git a/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go b/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go new file mode 100644 index 00000000000..14e468f767c --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go @@ -0,0 +1,21 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package gqlmodels + +type ExternalExtension struct { + Upc string `json:"upc"` + Reviews []*Hello `json:"reviews"` +} + +func (ExternalExtension) IsEntity() {} + +type ExternalExtensionByUpcsInput struct { + Upc string `json:"Upc"` +} + +type Hello struct { + Name string `json:"name"` + Secondary string `json:"secondary"` +} + +func (Hello) IsEntity() {} diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go b/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go new file mode 100644 index 00000000000..ee0e42eb0ad --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go @@ -0,0 +1,28 @@ +package resolvers + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.22-dev + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/generated" + "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" +) + +// FindManyExternalExtensionByUpcs is the resolver for the findManyExternalExtensionByUpcs field. +func (r *entityResolver) FindManyExternalExtensionByUpcs(ctx context.Context, reps []gqlmodels.ExternalExtensionByUpcsInput) ([]*gqlmodels.ExternalExtension, error) { + panic(fmt.Errorf("not implemented: FindManyExternalExtensionByUpcs - findManyExternalExtensionByUpcs")) +} + +// FindHelloByName is the resolver for the findHelloByName field. +func (r *entityResolver) FindHelloByName(ctx context.Context, name string) (*gqlmodels.Hello, error) { + panic(fmt.Errorf("not implemented: FindHelloByName - findHelloByName")) +} + +// Entity returns generated.EntityResolver implementation. +func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } + +type entityResolver struct{ *Resolver } diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/resolver.go b/plugin/federation/testdata/federatedentityresolver/resolvers/resolver.go new file mode 100644 index 00000000000..64236bc4780 --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/resolvers/resolver.go @@ -0,0 +1,7 @@ +package resolvers + +// This file will not be regenerated automatically. +// +// It serves as dependency injection for your app, add any dependencies you require here. + +type Resolver struct{} diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go b/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go new file mode 100644 index 00000000000..ad702f5f917 --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go @@ -0,0 +1,23 @@ +package resolvers + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.22-dev + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/generated" + "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" +) + +// Hello is the resolver for the hello field. +func (r *customQueryResolver) Hello(ctx context.Context) (*gqlmodels.Hello, error) { + panic(fmt.Errorf("not implemented: Hello - hello")) +} + +// CustomQuery returns generated.CustomQueryResolver implementation. +func (r *Resolver) CustomQuery() generated.CustomQueryResolver { return &customQueryResolver{r} } + +type customQueryResolver struct{ *Resolver } diff --git a/plugin/federation/testdata/federatedentityresolver/schema.graphql b/plugin/federation/testdata/federatedentityresolver/schema.graphql new file mode 100644 index 00000000000..e07c02c238a --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/schema.graphql @@ -0,0 +1,34 @@ +extend schema + @link( + url: "https://specs.apollo.dev/federation/v2.0" + import: [ + "@key" + "@shareable" + "@provides" + "@external" + "@tag" + "@extends" + "@override" + "@inaccessible" + ] + ) + +schema { + query: CustomQuery +} + +directive @entityResolver(multi: Boolean) on OBJECT + +type Hello @key(fields: "name") { + name: String! + secondary: String! +} + +extend type ExternalExtension @key(fields: "upc") @entityResolver(multi: true) { + upc: String! + reviews: [Hello] +} + +type CustomQuery { + hello: Hello +} diff --git a/plugin/federation/v2federation_entityresolver_test.go b/plugin/federation/v2federation_entityresolver_test.go new file mode 100644 index 00000000000..d08ff6d5230 --- /dev/null +++ b/plugin/federation/v2federation_entityresolver_test.go @@ -0,0 +1,92 @@ +//go:generate go run ../../testdata/gqlgen.go -config testdata/federatedentityresolver/gqlgen.yml +package federation + +// import ( +// "strconv" +// "testing" + +// "github.com/99designs/gqlgen/client" +// "github.com/99designs/gqlgen/graphql/handler" +// "github.com/stretchr/testify/require" + +// "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/generated" +// "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/resolvers" +// ) + +// func TestFederatedEntityResolver(t *testing.T) { +// c := client.New(handler.NewDefaultServer( +// generated.NewExecutableSchema(generated.Config{ +// Resolvers: &resolvers.Resolver{}, +// }), +// )) + +// t.Run("Hello entities", func(t *testing.T) { +// representations := []map[string]interface{}{ +// { +// "__typename": "Hello", +// "name": "first name - 1", +// }, { +// "__typename": "Hello", +// "name": "first name - 2", +// }, +// } + +// var resp struct { +// Entities []struct { +// Name string `json:"name"` +// } `json:"_entities"` +// } + +// err := c.Post( +// entityQuery([]string{ +// "Hello {name}", +// }), +// &resp, +// client.Var("representations", representations), +// ) + +// require.NoError(t, err) +// require.Equal(t, resp.Entities[0].Name, "first name - 1") +// require.Equal(t, resp.Entities[1].Name, "first name - 2") +// }) +// } + +// func TestFederatedMultiEntityResolver(t *testing.T) { +// c := client.New(handler.NewDefaultServer( +// generated.NewExecutableSchema(generated.Config{ +// Resolvers: &resolvers.Resolver{}, +// }), +// )) + +// t.Run("MultiHello entities", func(t *testing.T) { +// itemCount := 10 +// representations := []map[string]interface{}{} + +// for i := 0; i < itemCount; i++ { +// representations = append(representations, map[string]interface{}{ +// "__typename": "MultiHello", +// "name": "world name - " + strconv.Itoa(i), +// }) +// } + +// var resp struct { +// Entities []struct { +// Name string `json:"name"` +// } `json:"_entities"` +// } + +// err := c.Post( +// entityQuery([]string{ +// "MultiHello {name}", +// }), +// &resp, +// client.Var("representations", representations), +// ) + +// require.NoError(t, err) + +// for i := 0; i < itemCount; i++ { +// require.Equal(t, resp.Entities[i].Name, "world name - "+strconv.Itoa(i)+" - from multiget") +// } +// }) +// } From d2c511ad569c6a726d325ef3d3a3e59b6d79cb50 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Mon, 27 Mar 2023 14:02:05 +1100 Subject: [PATCH 2/4] Add _FieldSet type and autobind model package --- .../federatedentityresolver/generated/exec.go | 25 +++++++++++++++++++ .../federatedentityresolver/gqlgen.yml | 2 ++ .../gqlmodels/fieldset.go | 3 +++ .../gqlmodels/gqlmodels.go | 2 +- .../resolvers/entity.resolvers.go | 2 +- .../resolvers/schema.resolvers.go | 2 +- 6 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go diff --git a/plugin/federation/testdata/federatedentityresolver/generated/exec.go b/plugin/federation/testdata/federatedentityresolver/generated/exec.go index b2caba26fb5..9ce76e52ca6 100644 --- a/plugin/federation/testdata/federatedentityresolver/generated/exec.go +++ b/plugin/federation/testdata/federatedentityresolver/generated/exec.go @@ -9,6 +9,7 @@ import ( "fmt" "strconv" "sync" + "sync/atomic" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" @@ -446,6 +447,7 @@ func (ec *executionContext) _CustomQuery_hello(ctx context.Context, field graphq }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { return graphql.Null @@ -492,6 +494,7 @@ func (ec *executionContext) _CustomQuery__entities(ctx context.Context, field gr }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { @@ -546,6 +549,7 @@ func (ec *executionContext) _CustomQuery__service(ctx context.Context, field gra }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { @@ -593,6 +597,7 @@ func (ec *executionContext) _CustomQuery___type(ctx context.Context, field graph }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { return graphql.Null @@ -666,6 +671,7 @@ func (ec *executionContext) _CustomQuery___schema(ctx context.Context, field gra }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { return graphql.Null @@ -744,6 +750,7 @@ func (ec *executionContext) _Entity_findManyExternalExtensionByUpcs(ctx context. }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { return graphql.Null @@ -801,6 +808,7 @@ func (ec *executionContext) _Entity_findHelloByName(ctx context.Context, field g }) if err != nil { ec.Error(ctx, err) + return graphql.Null } if resTmp == nil { if !graphql.HasFieldError(ctx, fc) { @@ -2904,6 +2912,7 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS }) out := graphql.NewFieldSet(fields) + var invalids uint32 for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -2943,6 +2952,9 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS } }() res = ec._CustomQuery__entities(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res } @@ -2963,6 +2975,9 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS } }() res = ec._CustomQuery__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res } @@ -2990,6 +3005,9 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS } } out.Dispatch() + if invalids > 0 { + return graphql.Null + } return out } @@ -3002,6 +3020,7 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g }) out := graphql.NewFieldSet(fields) + var invalids uint32 for i, field := range fields { innerCtx := graphql.WithRootFieldContext(ctx, &graphql.RootFieldContext{ Object: field.Name, @@ -3041,6 +3060,9 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g } }() res = ec._Entity_findHelloByName(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } return res } @@ -3056,6 +3078,9 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g } } out.Dispatch() + if invalids > 0 { + return graphql.Null + } return out } diff --git a/plugin/federation/testdata/federatedentityresolver/gqlgen.yml b/plugin/federation/testdata/federatedentityresolver/gqlgen.yml index f63bb8336e1..35186fda7c8 100644 --- a/plugin/federation/testdata/federatedentityresolver/gqlgen.yml +++ b/plugin/federation/testdata/federatedentityresolver/gqlgen.yml @@ -10,6 +10,8 @@ federation: model: filename: testdata/federatedentityresolver/gqlmodels/gqlmodels.go package: gqlmodels +autobind: + - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" resolver: layout: follow-schema dir: testdata/federatedentityresolver/resolvers diff --git a/plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go b/plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go new file mode 100644 index 00000000000..45c94681df3 --- /dev/null +++ b/plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go @@ -0,0 +1,3 @@ +package gqlmodels + +type _FieldSet string //nolint:deadcode,unused diff --git a/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go b/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go index 14e468f767c..e9df746ec22 100644 --- a/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go +++ b/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go @@ -4,7 +4,7 @@ package gqlmodels type ExternalExtension struct { Upc string `json:"upc"` - Reviews []*Hello `json:"reviews"` + Reviews []*Hello `json:"reviews,omitempty"` } func (ExternalExtension) IsEntity() {} diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go b/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go index ee0e42eb0ad..e49859333a0 100644 --- a/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go +++ b/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.22-dev +// Code generated by github.com/99designs/gqlgen version v0.17.27-dev import ( "context" diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go b/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go index ad702f5f917..eda0ab8856c 100644 --- a/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go +++ b/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go @@ -2,7 +2,7 @@ package resolvers // This file will be automatically regenerated based on the schema, any resolver implementations // will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.22-dev +// Code generated by github.com/99designs/gqlgen version v0.17.27-dev import ( "context" From fdfd2b5ee45f3fc571f3985f5a50d345bfe61573 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Mon, 27 Mar 2023 16:38:02 +1100 Subject: [PATCH 3/4] Remove test and add to _examples federation --- _examples/federation/multi/gqlgen.yml | 28 + .../internal/graphql}/generated/federation.go | 63 +- .../internal/graphql/generated/generated.go | 981 +++++++----------- .../internal/graphql/gqlmodels/gqlmodels.go | 14 + .../graphql/resolvers/entity.resolvers.go | 23 + .../internal/graphql}/resolvers/resolver.go | 0 .../graphql/resolvers/schema.resolvers.go | 23 + .../internal/graphql/schema/schema.graphql | 10 + _examples/federation/multi/server.go | 32 + plugin/federation/federation_test.go | 10 - .../federatedentityresolver/gqlgen.yml | 28 - .../gqlmodels/fieldset.go | 3 - .../gqlmodels/gqlmodels.go | 21 - .../resolvers/entity.resolvers.go | 28 - .../resolvers/schema.resolvers.go | 23 - .../federatedentityresolver/schema.graphql | 34 - .../v2federation_entityresolver_test.go | 92 -- 17 files changed, 508 insertions(+), 905 deletions(-) create mode 100644 _examples/federation/multi/gqlgen.yml rename {plugin/federation/testdata/federatedentityresolver => _examples/federation/multi/internal/graphql}/generated/federation.go (71%) rename plugin/federation/testdata/federatedentityresolver/generated/exec.go => _examples/federation/multi/internal/graphql/generated/generated.go (83%) create mode 100644 _examples/federation/multi/internal/graphql/gqlmodels/gqlmodels.go create mode 100644 _examples/federation/multi/internal/graphql/resolvers/entity.resolvers.go rename {plugin/federation/testdata/federatedentityresolver => _examples/federation/multi/internal/graphql}/resolvers/resolver.go (100%) create mode 100644 _examples/federation/multi/internal/graphql/resolvers/schema.resolvers.go create mode 100644 _examples/federation/multi/internal/graphql/schema/schema.graphql create mode 100644 _examples/federation/multi/server.go delete mode 100644 plugin/federation/testdata/federatedentityresolver/gqlgen.yml delete mode 100644 plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go delete mode 100644 plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go delete mode 100644 plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go delete mode 100644 plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go delete mode 100644 plugin/federation/testdata/federatedentityresolver/schema.graphql delete mode 100644 plugin/federation/v2federation_entityresolver_test.go diff --git a/_examples/federation/multi/gqlgen.yml b/_examples/federation/multi/gqlgen.yml new file mode 100644 index 00000000000..61cd05f4275 --- /dev/null +++ b/_examples/federation/multi/gqlgen.yml @@ -0,0 +1,28 @@ +schema: + - internal/graphql/schema/**/*.graphql + +exec: + filename: internal/graphql/generated/generated.go + package: generated + +federation: + filename: internal/graphql/generated/federation.go + package: generated + version: 2 + +model: + filename: internal/graphql/gqlmodels/gqlmodels.go + package: gqlmodels + +resolver: + layout: follow-schema + dir: internal/graphql/resolvers + package: resolvers + filename_template: "{name}.resolvers.go" + +models: + ID: + model: + - github.com/99designs/gqlgen/graphql.String + - github.com/99designs/gqlgen/graphql.Int + - github.com/99designs/gqlgen/graphql.ID diff --git a/plugin/federation/testdata/federatedentityresolver/generated/federation.go b/_examples/federation/multi/internal/graphql/generated/federation.go similarity index 71% rename from plugin/federation/testdata/federatedentityresolver/generated/federation.go rename to _examples/federation/multi/internal/graphql/generated/federation.go index 4a3867be6ea..b99361f6dde 100644 --- a/plugin/federation/testdata/federatedentityresolver/generated/federation.go +++ b/_examples/federation/multi/internal/graphql/generated/federation.go @@ -9,8 +9,8 @@ import ( "strings" "sync" + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/gqlmodels" "github.com/99designs/gqlgen/plugin/federation/fedruntime" - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" ) var ( @@ -66,7 +66,7 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati isMulti := func(typeName string) bool { switch typeName { - case "ExternalExtension": + case "Customer": return true default: return false @@ -83,26 +83,6 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati }() switch typeName { - case "Hello": - resolverName, err := entityResolverNameForHello(ctx, rep) - if err != nil { - return fmt.Errorf(`finding resolver for Entity "Hello": %w`, err) - } - switch resolverName { - - case "findHelloByName": - id0, err := ec.unmarshalNString2string(ctx, rep["name"]) - if err != nil { - return fmt.Errorf(`unmarshalling param 0 for findHelloByName(): %w`, err) - } - entity, err := ec.resolvers.Entity().FindHelloByName(ctx, id0) - if err != nil { - return fmt.Errorf(`resolving Entity "Hello": %w`, err) - } - - list[idx[i]] = entity - return nil - } } return fmt.Errorf("%w: %s", ErrUnknownType, typeName) @@ -119,21 +99,21 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati switch typeName { - case "ExternalExtension": - _reps := make([]*gqlmodels.ExternalExtensionByUpcsInput, len(reps)) + case "Customer": + _reps := make([]*gqlmodels.CustomerByIDsInput, len(reps)) for i, rep := range reps { - id0, err := ec.unmarshalNString2string(ctx, rep["upc"]) + id0, err := ec.unmarshalNID2string(ctx, rep["id"]) if err != nil { - return errors.New(fmt.Sprintf("Field %s undefined in schema.", "upc")) + return errors.New(fmt.Sprintf("Field %s undefined in schema.", "id")) } - _reps[i] = &gqlmodels.ExternalExtensionByUpcsInput{ - Upc: id0, + _reps[i] = &gqlmodels.CustomerByIDsInput{ + ID: id0, } } - entities, err := ec.resolvers.Entity().FindManyExternalExtensionByUpcs(ctx, _reps) + entities, err := ec.resolvers.Entity().FindManyCustomerByIDs(ctx, _reps) if err != nil { return err } @@ -196,24 +176,7 @@ func (ec *executionContext) __resolve_entities(ctx context.Context, representati } } -func entityResolverNameForExternalExtension(ctx context.Context, rep map[string]interface{}) (string, error) { - for { - var ( - m map[string]interface{} - val interface{} - ok bool - ) - _ = val - m = rep - if _, ok = m["upc"]; !ok { - break - } - return "findManyExternalExtensionByUpcs", nil - } - return "", fmt.Errorf("%w for ExternalExtension", ErrTypeNotFound) -} - -func entityResolverNameForHello(ctx context.Context, rep map[string]interface{}) (string, error) { +func entityResolverNameForCustomer(ctx context.Context, rep map[string]interface{}) (string, error) { for { var ( m map[string]interface{} @@ -222,10 +185,10 @@ func entityResolverNameForHello(ctx context.Context, rep map[string]interface{}) ) _ = val m = rep - if _, ok = m["name"]; !ok { + if _, ok = m["id"]; !ok { break } - return "findHelloByName", nil + return "findManyCustomerByIDs", nil } - return "", fmt.Errorf("%w for Hello", ErrTypeNotFound) + return "", fmt.Errorf("%w for Customer", ErrTypeNotFound) } diff --git a/plugin/federation/testdata/federatedentityresolver/generated/exec.go b/_examples/federation/multi/internal/graphql/generated/generated.go similarity index 83% rename from plugin/federation/testdata/federatedentityresolver/generated/exec.go rename to _examples/federation/multi/internal/graphql/generated/generated.go index 9ce76e52ca6..a6b94641997 100644 --- a/plugin/federation/testdata/federatedentityresolver/generated/exec.go +++ b/_examples/federation/multi/internal/graphql/generated/generated.go @@ -11,10 +11,11 @@ import ( "sync" "sync/atomic" + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/gqlmodels" "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/plugin/federation/fedruntime" - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" + "github.com/99designs/gqlgen/plugin/federation/fieldset" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) @@ -37,8 +38,8 @@ type Config struct { } type ResolverRoot interface { - CustomQuery() CustomQueryResolver Entity() EntityResolver + Query() QueryResolver } type DirectiveRoot struct { @@ -46,25 +47,19 @@ type DirectiveRoot struct { } type ComplexityRoot struct { - CustomQuery struct { - Hello func(childComplexity int) int - __resolve__service func(childComplexity int) int - __resolve_entities func(childComplexity int, representations []map[string]interface{}) int + Customer struct { + ID func(childComplexity int) int + Name func(childComplexity int) int } Entity struct { - FindHelloByName func(childComplexity int, name string) int - FindManyExternalExtensionByUpcs func(childComplexity int, reps []gqlmodels.ExternalExtensionByUpcsInput) int - } - - ExternalExtension struct { - Reviews func(childComplexity int) int - Upc func(childComplexity int) int + FindManyCustomerByIDs func(childComplexity int, reps []*gqlmodels.CustomerByIDsInput) int } - Hello struct { - Name func(childComplexity int) int - Secondary func(childComplexity int) int + Query struct { + Customers func(childComplexity int, ids []string) int + __resolve__service func(childComplexity int) int + __resolve_entities func(childComplexity int, representations []map[string]interface{}) int } _Service struct { @@ -72,12 +67,11 @@ type ComplexityRoot struct { } } -type CustomQueryResolver interface { - Hello(ctx context.Context) (*gqlmodels.Hello, error) -} type EntityResolver interface { - FindManyExternalExtensionByUpcs(ctx context.Context, reps []gqlmodels.ExternalExtensionByUpcsInput) ([]*gqlmodels.ExternalExtension, error) - FindHelloByName(ctx context.Context, name string) (*gqlmodels.Hello, error) + FindManyCustomerByIDs(ctx context.Context, reps []*gqlmodels.CustomerByIDsInput) ([]*gqlmodels.Customer, error) +} +type QueryResolver interface { + Customers(ctx context.Context, ids []string) ([]*gqlmodels.Customer, error) } type executableSchema struct { @@ -95,83 +89,62 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in _ = ec switch typeName + "." + field { - case "CustomQuery.hello": - if e.complexity.CustomQuery.Hello == nil { + case "Customer.id": + if e.complexity.Customer.ID == nil { break } - return e.complexity.CustomQuery.Hello(childComplexity), true + return e.complexity.Customer.ID(childComplexity), true - case "CustomQuery._service": - if e.complexity.CustomQuery.__resolve__service == nil { + case "Customer.name": + if e.complexity.Customer.Name == nil { break } - return e.complexity.CustomQuery.__resolve__service(childComplexity), true + return e.complexity.Customer.Name(childComplexity), true - case "CustomQuery._entities": - if e.complexity.CustomQuery.__resolve_entities == nil { + case "Entity.findManyCustomerByIDs": + if e.complexity.Entity.FindManyCustomerByIDs == nil { break } - args, err := ec.field_CustomQuery__entities_args(context.TODO(), rawArgs) + args, err := ec.field_Entity_findManyCustomerByIDs_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.CustomQuery.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true + return e.complexity.Entity.FindManyCustomerByIDs(childComplexity, args["reps"].([]*gqlmodels.CustomerByIDsInput)), true - case "Entity.findHelloByName": - if e.complexity.Entity.FindHelloByName == nil { + case "Query.customers": + if e.complexity.Query.Customers == nil { break } - args, err := ec.field_Entity_findHelloByName_args(context.TODO(), rawArgs) + args, err := ec.field_Query_customers_args(context.TODO(), rawArgs) if err != nil { return 0, false } - return e.complexity.Entity.FindHelloByName(childComplexity, args["name"].(string)), true + return e.complexity.Query.Customers(childComplexity, args["ids"].([]string)), true - case "Entity.findManyExternalExtensionByUpcs": - if e.complexity.Entity.FindManyExternalExtensionByUpcs == nil { + case "Query._service": + if e.complexity.Query.__resolve__service == nil { break } - args, err := ec.field_Entity_findManyExternalExtensionByUpcs_args(context.TODO(), rawArgs) - if err != nil { - return 0, false - } + return e.complexity.Query.__resolve__service(childComplexity), true - return e.complexity.Entity.FindManyExternalExtensionByUpcs(childComplexity, args["reps"].([]gqlmodels.ExternalExtensionByUpcsInput)), true - - case "ExternalExtension.reviews": - if e.complexity.ExternalExtension.Reviews == nil { - break - } - - return e.complexity.ExternalExtension.Reviews(childComplexity), true - - case "ExternalExtension.upc": - if e.complexity.ExternalExtension.Upc == nil { + case "Query._entities": + if e.complexity.Query.__resolve_entities == nil { break } - return e.complexity.ExternalExtension.Upc(childComplexity), true - - case "Hello.name": - if e.complexity.Hello.Name == nil { - break - } - - return e.complexity.Hello.Name(childComplexity), true - - case "Hello.secondary": - if e.complexity.Hello.Secondary == nil { - break + args, err := ec.field_Query__entities_args(context.TODO(), rawArgs) + if err != nil { + return 0, false } - return e.complexity.Hello.Secondary(childComplexity), true + return e.complexity.Query.__resolve_entities(childComplexity, args["representations"].([]map[string]interface{})), true case "_Service.sdl": if e.complexity._Service.SDL == nil { @@ -188,7 +161,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { rc := graphql.GetOperationContext(ctx) ec := executionContext{rc, e} inputUnmarshalMap := graphql.BuildUnmarshalerMap( - ec.unmarshalInputExternalExtensionByUpcsInput, + ec.unmarshalInputCustomerByIDsInput, ) first := true @@ -200,7 +173,7 @@ func (e *executableSchema) Exec(ctx context.Context) graphql.ResponseHandler { } first = false ctx = graphql.WithUnmarshalerMap(ctx, inputUnmarshalMap) - data := ec._CustomQuery(ctx, rc.Operation.SelectionSet) + data := ec._Query(ctx, rc.Operation.SelectionSet) var buf bytes.Buffer data.MarshalGQL(&buf) @@ -234,39 +207,15 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er } var sources = []*ast.Source{ - {Name: "../schema.graphql", Input: `extend schema - @link( - url: "https://specs.apollo.dev/federation/v2.0" - import: [ - "@key" - "@shareable" - "@provides" - "@external" - "@tag" - "@extends" - "@override" - "@inaccessible" - ] - ) - -schema { - query: CustomQuery -} - -directive @entityResolver(multi: Boolean) on OBJECT + {Name: "../schema/schema.graphql", Input: `directive @entityResolver(multi: Boolean) on OBJECT -type Hello @key(fields: "name") { - name: String! - secondary: String! +type Customer @key(fields: "id") @entityResolver(multi: true) { + id: ID! + name: String } -extend type ExternalExtension @key(fields: "upc") @entityResolver(multi: true) { - upc: String! - reviews: [Hello] -} - -type CustomQuery { - hello: Hello +type Query { + customers(ids: [ID!]!): [Customer] } `, BuiltIn: false}, {Name: "../../../federation/directives.graphql", Input: ` @@ -287,16 +236,15 @@ type CustomQuery { `, BuiltIn: true}, {Name: "../../../federation/entity.graphql", Input: ` # a union of all types that use the @key directive -union _Entity = ExternalExtension | Hello +union _Entity = Customer -input ExternalExtensionByUpcsInput { - Upc: String! +input CustomerByIDsInput { + ID: ID! } # fake type to build resolver interfaces for users to implement type Entity { - findManyExternalExtensionByUpcs(reps: [ExternalExtensionByUpcsInput!]!): [ExternalExtension] - findHelloByName(name: String!,): Hello! + findManyCustomerByIDs(reps: [CustomerByIDsInput!]!): [Customer] } @@ -304,7 +252,7 @@ type _Service { sdl: String } -extend type CustomQuery { +extend type Query { _entities(representations: [_Any!]!): [_Entity]! _service: _Service! } @@ -331,7 +279,22 @@ func (ec *executionContext) dir_entityResolver_args(ctx context.Context, rawArgs return args, nil } -func (ec *executionContext) field_CustomQuery___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Entity_findManyCustomerByIDs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { + var err error + args := map[string]interface{}{} + var arg0 []*gqlmodels.CustomerByIDsInput + if tmp, ok := rawArgs["reps"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) + arg0, err = ec.unmarshalNCustomerByIDsInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomerByIDsInputᚄ(ctx, tmp) + if err != nil { + return nil, err + } + } + args["reps"] = arg0 + return args, nil +} + +func (ec *executionContext) field_Query___type_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 string @@ -346,7 +309,7 @@ func (ec *executionContext) field_CustomQuery___type_args(ctx context.Context, r return args, nil } -func (ec *executionContext) field_CustomQuery__entities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query__entities_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} var arg0 []map[string]interface{} @@ -361,33 +324,18 @@ func (ec *executionContext) field_CustomQuery__entities_args(ctx context.Context return args, nil } -func (ec *executionContext) field_Entity_findHelloByName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { - var err error - args := map[string]interface{}{} - var arg0 string - if tmp, ok := rawArgs["name"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("name")) - arg0, err = ec.unmarshalNString2string(ctx, tmp) - if err != nil { - return nil, err - } - } - args["name"] = arg0 - return args, nil -} - -func (ec *executionContext) field_Entity_findManyExternalExtensionByUpcs_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { +func (ec *executionContext) field_Query_customers_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} - var arg0 []gqlmodels.ExternalExtensionByUpcsInput - if tmp, ok := rawArgs["reps"]; ok { - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("reps")) - arg0, err = ec.unmarshalNExternalExtensionByUpcsInput2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInputᚄ(ctx, tmp) + var arg0 []string + if tmp, ok := rawArgs["ids"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ids")) + arg0, err = ec.unmarshalNID2ᚕstringᚄ(ctx, tmp) if err != nil { return nil, err } } - args["reps"] = arg0 + args["ids"] = arg0 return args, nil } @@ -429,55 +377,8 @@ func (ec *executionContext) field___Type_fields_args(ctx context.Context, rawArg // region **************************** field.gotpl ***************************** -func (ec *executionContext) _CustomQuery_hello(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CustomQuery_hello(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.CustomQuery().Hello(rctx) - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*gqlmodels.Hello) - fc.Result = res - return ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CustomQuery_hello(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CustomQuery", - Field: field, - IsMethod: true, - IsResolver: true, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Hello_name(ctx, field) - case "secondary": - return ec.fieldContext_Hello_secondary(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _CustomQuery__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CustomQuery__entities(ctx, field) +func (ec *executionContext) _Customer_id(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.Customer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Customer_id(ctx, field) if err != nil { return graphql.Null } @@ -490,7 +391,7 @@ func (ec *executionContext) _CustomQuery__entities(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]interface{})), nil + return obj.ID, nil }) if err != nil { ec.Error(ctx, err) @@ -502,37 +403,26 @@ func (ec *executionContext) _CustomQuery__entities(ctx context.Context, field gr } return graphql.Null } - res := resTmp.([]fedruntime.Entity) + res := resTmp.(string) fc.Result = res - return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) + return ec.marshalNID2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CustomQuery__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Customer_id(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "CustomQuery", + Object: "Customer", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type _Entity does not have child fields") + return nil, errors.New("field of type ID does not have child fields") }, } - defer func() { - if r := recover(); r != nil { - err = ec.Recover(ctx, r) - ec.Error(ctx, err) - } - }() - ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_CustomQuery__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { - ec.Error(ctx, err) - return - } return fc, nil } -func (ec *executionContext) _CustomQuery__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CustomQuery__service(ctx, field) +func (ec *executionContext) _Customer_name(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.Customer) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Customer_name(ctx, field) if err != nil { return graphql.Null } @@ -545,42 +435,35 @@ func (ec *executionContext) _CustomQuery__service(ctx context.Context, field gra }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.__resolve__service(ctx) + return obj.Name, nil }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(fedruntime.Service) + res := resTmp.(*string) fc.Result = res - return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) + return ec.marshalOString2ᚖstring(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CustomQuery__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Customer_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "CustomQuery", + Object: "Customer", Field: field, - IsMethod: true, + IsMethod: false, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "sdl": - return ec.fieldContext__Service_sdl(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) + return nil, errors.New("field of type String does not have child fields") }, } return fc, nil } -func (ec *executionContext) _CustomQuery___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CustomQuery___type(ctx, field) +func (ec *executionContext) _Entity_findManyCustomerByIDs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Entity_findManyCustomerByIDs(ctx, field) if err != nil { return graphql.Null } @@ -592,8 +475,32 @@ func (ec *executionContext) _CustomQuery___type(ctx context.Context, field graph } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectType(fc.Args["name"].(string)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyCustomerByIDs(rctx, fc.Args["reps"].([]*gqlmodels.CustomerByIDsInput)) + } + directive1 := func(ctx context.Context) (interface{}, error) { + multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) + if err != nil { + return nil, err + } + if ec.directives.EntityResolver == nil { + return nil, errors.New("directive entityResolver is not implemented") + } + return ec.directives.EntityResolver(ctx, nil, directive0, multi) + } + + tmp, err := directive1(rctx) + if err != nil { + return nil, graphql.ErrorOnPath(ctx, err) + } + if tmp == nil { + return nil, nil + } + if data, ok := tmp.([]*gqlmodels.Customer); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/gqlmodels.Customer`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -602,41 +509,25 @@ func (ec *executionContext) _CustomQuery___type(ctx context.Context, field graph if resTmp == nil { return graphql.Null } - res := resTmp.(*introspection.Type) + res := resTmp.([]*gqlmodels.Customer) fc.Result = res - return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) + return ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomer(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_CustomQuery___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Entity_findManyCustomerByIDs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "CustomQuery", + Object: "Entity", Field: field, IsMethod: true, - IsResolver: false, + IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "kind": - return ec.fieldContext___Type_kind(ctx, field) + case "id": + return ec.fieldContext_Customer_id(ctx, field) case "name": - return ec.fieldContext___Type_name(ctx, field) - case "description": - return ec.fieldContext___Type_description(ctx, field) - case "fields": - return ec.fieldContext___Type_fields(ctx, field) - case "interfaces": - return ec.fieldContext___Type_interfaces(ctx, field) - case "possibleTypes": - return ec.fieldContext___Type_possibleTypes(ctx, field) - case "enumValues": - return ec.fieldContext___Type_enumValues(ctx, field) - case "inputFields": - return ec.fieldContext___Type_inputFields(ctx, field) - case "ofType": - return ec.fieldContext___Type_ofType(ctx, field) - case "specifiedByURL": - return ec.fieldContext___Type_specifiedByURL(ctx, field) + return ec.fieldContext_Customer_name(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) }, } defer func() { @@ -646,70 +537,15 @@ func (ec *executionContext) fieldContext_CustomQuery___type(ctx context.Context, } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_CustomQuery___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Entity_findManyCustomerByIDs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } -func (ec *executionContext) _CustomQuery___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_CustomQuery___schema(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null - } - }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.introspectSchema() - }) - if err != nil { - ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - return graphql.Null - } - res := resTmp.(*introspection.Schema) - fc.Result = res - return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_CustomQuery___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "CustomQuery", - Field: field, - IsMethod: true, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "description": - return ec.fieldContext___Schema_description(ctx, field) - case "types": - return ec.fieldContext___Schema_types(ctx, field) - case "queryType": - return ec.fieldContext___Schema_queryType(ctx, field) - case "mutationType": - return ec.fieldContext___Schema_mutationType(ctx, field) - case "subscriptionType": - return ec.fieldContext___Schema_subscriptionType(ctx, field) - case "directives": - return ec.fieldContext___Schema_directives(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) - }, - } - return fc, nil -} - -func (ec *executionContext) _Entity_findManyExternalExtensionByUpcs(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Entity_findManyExternalExtensionByUpcs(ctx, field) +func (ec *executionContext) _Query_customers(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query_customers(ctx, field) if err != nil { return graphql.Null } @@ -723,7 +559,7 @@ func (ec *executionContext) _Entity_findManyExternalExtensionByUpcs(ctx context. resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { directive0 := func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindManyExternalExtensionByUpcs(rctx, fc.Args["reps"].([]gqlmodels.ExternalExtensionByUpcsInput)) + return ec.resolvers.Query().Customers(rctx, fc.Args["ids"].([]string)) } directive1 := func(ctx context.Context) (interface{}, error) { multi, err := ec.unmarshalOBoolean2ᚖbool(ctx, true) @@ -743,10 +579,10 @@ func (ec *executionContext) _Entity_findManyExternalExtensionByUpcs(ctx context. if tmp == nil { return nil, nil } - if data, ok := tmp.([]*gqlmodels.ExternalExtension); ok { + if data, ok := tmp.([]*gqlmodels.Customer); ok { return data, nil } - return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels.ExternalExtension`, tmp) + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/gqlmodels.Customer`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -755,25 +591,25 @@ func (ec *executionContext) _Entity_findManyExternalExtensionByUpcs(ctx context. if resTmp == nil { return graphql.Null } - res := resTmp.([]*gqlmodels.ExternalExtension) + res := resTmp.([]*gqlmodels.Customer) fc.Result = res - return ec.marshalOExternalExtension2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx, field.Selections, res) + return ec.marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomer(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Entity_findManyExternalExtensionByUpcs(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query_customers(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Entity", + Object: "Query", Field: field, IsMethod: true, IsResolver: true, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { - case "upc": - return ec.fieldContext_ExternalExtension_upc(ctx, field) - case "reviews": - return ec.fieldContext_ExternalExtension_reviews(ctx, field) + case "id": + return ec.fieldContext_Customer_id(ctx, field) + case "name": + return ec.fieldContext_Customer_name(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type ExternalExtension", field.Name) + return nil, fmt.Errorf("no field named %q was found under type Customer", field.Name) }, } defer func() { @@ -783,15 +619,15 @@ func (ec *executionContext) fieldContext_Entity_findManyExternalExtensionByUpcs( } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Entity_findManyExternalExtensionByUpcs_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query_customers_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } -func (ec *executionContext) _Entity_findHelloByName(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Entity_findHelloByName(ctx, field) +func (ec *executionContext) _Query__entities(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__entities(ctx, field) if err != nil { return graphql.Null } @@ -804,7 +640,7 @@ func (ec *executionContext) _Entity_findHelloByName(ctx context.Context, field g }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindHelloByName(rctx, fc.Args["name"].(string)) + return ec.__resolve_entities(ctx, fc.Args["representations"].([]map[string]interface{})), nil }) if err != nil { ec.Error(ctx, err) @@ -816,25 +652,19 @@ func (ec *executionContext) _Entity_findHelloByName(ctx context.Context, field g } return graphql.Null } - res := resTmp.(*gqlmodels.Hello) + res := resTmp.([]fedruntime.Entity) fc.Result = res - return ec.marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, field.Selections, res) + return ec.marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐEntity(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Entity_findHelloByName(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query__entities(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Entity", + Object: "Query", Field: field, IsMethod: true, - IsResolver: true, + IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - switch field.Name { - case "name": - return ec.fieldContext_Hello_name(ctx, field) - case "secondary": - return ec.fieldContext_Hello_secondary(ctx, field) - } - return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + return nil, errors.New("field of type _Entity does not have child fields") }, } defer func() { @@ -844,15 +674,15 @@ func (ec *executionContext) fieldContext_Entity_findHelloByName(ctx context.Cont } }() ctx = graphql.WithFieldContext(ctx, fc) - if fc.Args, err = ec.field_Entity_findHelloByName_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { + if fc.Args, err = ec.field_Query__entities_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) return } return fc, nil } -func (ec *executionContext) _ExternalExtension_upc(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.ExternalExtension) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ExternalExtension_upc(ctx, field) +func (ec *executionContext) _Query__service(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query__service(ctx, field) if err != nil { return graphql.Null } @@ -865,7 +695,7 @@ func (ec *executionContext) _ExternalExtension_upc(ctx context.Context, field gr }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Upc, nil + return ec.__resolve__service(ctx) }) if err != nil { ec.Error(ctx, err) @@ -877,26 +707,30 @@ func (ec *executionContext) _ExternalExtension_upc(ctx context.Context, field gr } return graphql.Null } - res := resTmp.(string) + res := resTmp.(fedruntime.Service) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalN_Service2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfedruntimeᚐService(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ExternalExtension_upc(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query__service(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ExternalExtension", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "sdl": + return ec.fieldContext__Service_sdl(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type _Service", field.Name) }, } return fc, nil } -func (ec *executionContext) _ExternalExtension_reviews(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.ExternalExtension) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_ExternalExtension_reviews(ctx, field) +func (ec *executionContext) _Query___type(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___type(ctx, field) if err != nil { return graphql.Null } @@ -909,7 +743,7 @@ func (ec *executionContext) _ExternalExtension_reviews(ctx context.Context, fiel }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Reviews, nil + return ec.introspectType(fc.Args["name"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -918,76 +752,59 @@ func (ec *executionContext) _ExternalExtension_reviews(ctx context.Context, fiel if resTmp == nil { return graphql.Null } - res := resTmp.([]*gqlmodels.Hello) + res := resTmp.(*introspection.Type) fc.Result = res - return ec.marshalOHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, field.Selections, res) + return ec.marshalO__Type2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐType(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_ExternalExtension_reviews(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___type(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "ExternalExtension", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { switch field.Name { + case "kind": + return ec.fieldContext___Type_kind(ctx, field) case "name": - return ec.fieldContext_Hello_name(ctx, field) - case "secondary": - return ec.fieldContext_Hello_secondary(ctx, field) + return ec.fieldContext___Type_name(ctx, field) + case "description": + return ec.fieldContext___Type_description(ctx, field) + case "fields": + return ec.fieldContext___Type_fields(ctx, field) + case "interfaces": + return ec.fieldContext___Type_interfaces(ctx, field) + case "possibleTypes": + return ec.fieldContext___Type_possibleTypes(ctx, field) + case "enumValues": + return ec.fieldContext___Type_enumValues(ctx, field) + case "inputFields": + return ec.fieldContext___Type_inputFields(ctx, field) + case "ofType": + return ec.fieldContext___Type_ofType(ctx, field) + case "specifiedByURL": + return ec.fieldContext___Type_specifiedByURL(ctx, field) } - return nil, fmt.Errorf("no field named %q was found under type Hello", field.Name) + return nil, fmt.Errorf("no field named %q was found under type __Type", field.Name) }, } - return fc, nil -} - -func (ec *executionContext) _Hello_name(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.Hello) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Hello_name(ctx, field) - if err != nil { - return graphql.Null - } - ctx = graphql.WithFieldContext(ctx, fc) defer func() { if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - ret = graphql.Null + err = ec.Recover(ctx, r) + ec.Error(ctx, err) } }() - resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return obj.Name, nil - }) - if err != nil { + ctx = graphql.WithFieldContext(ctx, fc) + if fc.Args, err = ec.field_Query___type_args(ctx, field.ArgumentMap(ec.Variables)); err != nil { ec.Error(ctx, err) - return graphql.Null - } - if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } - return graphql.Null - } - res := resTmp.(string) - fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) -} - -func (ec *executionContext) fieldContext_Hello_name(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { - fc = &graphql.FieldContext{ - Object: "Hello", - Field: field, - IsMethod: false, - IsResolver: false, - Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") - }, + return } return fc, nil } -func (ec *executionContext) _Hello_secondary(ctx context.Context, field graphql.CollectedField, obj *gqlmodels.Hello) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Hello_secondary(ctx, field) +func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Query___schema(ctx, field) if err != nil { return graphql.Null } @@ -1000,31 +817,42 @@ func (ec *executionContext) _Hello_secondary(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Secondary, nil + return ec.introspectSchema() }) if err != nil { ec.Error(ctx, err) return graphql.Null } if resTmp == nil { - if !graphql.HasFieldError(ctx, fc) { - ec.Errorf(ctx, "must not be null") - } return graphql.Null } - res := resTmp.(string) + res := resTmp.(*introspection.Schema) fc.Result = res - return ec.marshalNString2string(ctx, field.Selections, res) + return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Hello_secondary(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Query___schema(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ - Object: "Hello", + Object: "Query", Field: field, - IsMethod: false, + IsMethod: true, IsResolver: false, Child: func(ctx context.Context, field graphql.CollectedField) (*graphql.FieldContext, error) { - return nil, errors.New("field of type String does not have child fields") + switch field.Name { + case "description": + return ec.fieldContext___Schema_description(ctx, field) + case "types": + return ec.fieldContext___Schema_types(ctx, field) + case "queryType": + return ec.fieldContext___Schema_queryType(ctx, field) + case "mutationType": + return ec.fieldContext___Schema_mutationType(ctx, field) + case "subscriptionType": + return ec.fieldContext___Schema_subscriptionType(ctx, field) + case "directives": + return ec.fieldContext___Schema_directives(ctx, field) + } + return nil, fmt.Errorf("no field named %q was found under type __Schema", field.Name) }, } return fc, nil @@ -2844,25 +2672,25 @@ func (ec *executionContext) fieldContext___Type_specifiedByURL(ctx context.Conte // region **************************** input.gotpl ***************************** -func (ec *executionContext) unmarshalInputExternalExtensionByUpcsInput(ctx context.Context, obj interface{}) (gqlmodels.ExternalExtensionByUpcsInput, error) { - var it gqlmodels.ExternalExtensionByUpcsInput +func (ec *executionContext) unmarshalInputCustomerByIDsInput(ctx context.Context, obj interface{}) (gqlmodels.CustomerByIDsInput, error) { + var it gqlmodels.CustomerByIDsInput asMap := map[string]interface{}{} for k, v := range obj.(map[string]interface{}) { asMap[k] = v } - fieldsInOrder := [...]string{"Upc"} + fieldsInOrder := [...]string{"ID"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { continue } switch k { - case "Upc": + case "ID": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("Upc")) - it.Upc, err = ec.unmarshalNString2string(ctx, v) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("ID")) + it.ID, err = ec.unmarshalNID2string(ctx, v) if err != nil { return it, err } @@ -2880,20 +2708,13 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, switch obj := (obj).(type) { case nil: return graphql.Null - case gqlmodels.ExternalExtension: - return ec._ExternalExtension(ctx, sel, &obj) - case *gqlmodels.ExternalExtension: + case gqlmodels.Customer: + return ec._Customer(ctx, sel, &obj) + case *gqlmodels.Customer: if obj == nil { return graphql.Null } - return ec._ExternalExtension(ctx, sel, obj) - case gqlmodels.Hello: - return ec._Hello(ctx, sel, &obj) - case *gqlmodels.Hello: - if obj == nil { - return graphql.Null - } - return ec._Hello(ctx, sel, obj) + return ec._Customer(ctx, sel, obj) default: panic(fmt.Errorf("unexpected type %T", obj)) } @@ -2903,12 +2724,44 @@ func (ec *executionContext) __Entity(ctx context.Context, sel ast.SelectionSet, // region **************************** object.gotpl **************************** -var customQueryImplementors = []string{"CustomQuery"} +var customerImplementors = []string{"Customer", "_Entity"} + +func (ec *executionContext) _Customer(ctx context.Context, sel ast.SelectionSet, obj *gqlmodels.Customer) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, customerImplementors) + out := graphql.NewFieldSet(fields) + var invalids uint32 + for i, field := range fields { + switch field.Name { + case "__typename": + out.Values[i] = graphql.MarshalString("Customer") + case "id": + + out.Values[i] = ec._Customer_id(ctx, field, obj) + + if out.Values[i] == graphql.Null { + invalids++ + } + case "name": + + out.Values[i] = ec._Customer_name(ctx, field, obj) + + default: + panic("unknown field " + strconv.Quote(field.Name)) + } + } + out.Dispatch() + if invalids > 0 { + return graphql.Null + } + return out +} + +var entityImplementors = []string{"Entity"} -func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, customQueryImplementors) +func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "CustomQuery", + Object: "Entity", }) out := graphql.NewFieldSet(fields) @@ -2921,51 +2774,8 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("CustomQuery") - case "hello": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CustomQuery_hello(ctx, field) - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "_entities": - field := field - - innerFunc := func(ctx context.Context) (res graphql.Marshaler) { - defer func() { - if r := recover(); r != nil { - ec.Error(ctx, ec.Recover(ctx, r)) - } - }() - res = ec._CustomQuery__entities(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } - return res - } - - rrm := func(ctx context.Context) graphql.Marshaler { - return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) - } - - out.Concurrently(i, func() graphql.Marshaler { - return rrm(innerCtx) - }) - case "_service": + out.Values[i] = graphql.MarshalString("Entity") + case "findManyCustomerByIDs": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -2974,10 +2784,7 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._CustomQuery__service(ctx, field) - if res == graphql.Null { - atomic.AddUint32(&invalids, 1) - } + res = ec._Entity_findManyCustomerByIDs(ctx, field) return res } @@ -2988,18 +2795,6 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS out.Concurrently(i, func() graphql.Marshaler { return rrm(innerCtx) }) - case "__type": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._CustomQuery___type(ctx, field) - }) - - case "__schema": - - out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { - return ec._CustomQuery___schema(ctx, field) - }) - default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -3011,12 +2806,12 @@ func (ec *executionContext) _CustomQuery(ctx context.Context, sel ast.SelectionS return out } -var entityImplementors = []string{"Entity"} +var queryImplementors = []string{"Query"} -func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) +func (ec *executionContext) _Query(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { + fields := graphql.CollectFields(ec.OperationContext, sel, queryImplementors) ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Entity", + Object: "Query", }) out := graphql.NewFieldSet(fields) @@ -3029,8 +2824,8 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g switch field.Name { case "__typename": - out.Values[i] = graphql.MarshalString("Entity") - case "findManyExternalExtensionByUpcs": + out.Values[i] = graphql.MarshalString("Query") + case "customers": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -3039,7 +2834,7 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Entity_findManyExternalExtensionByUpcs(ctx, field) + res = ec._Query_customers(ctx, field) return res } @@ -3050,7 +2845,7 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g out.Concurrently(i, func() graphql.Marshaler { return rrm(innerCtx) }) - case "findHelloByName": + case "_entities": field := field innerFunc := func(ctx context.Context) (res graphql.Marshaler) { @@ -3059,7 +2854,7 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Entity_findHelloByName(ctx, field) + res = ec._Query__entities(ctx, field) if res == graphql.Null { atomic.AddUint32(&invalids, 1) } @@ -3073,73 +2868,41 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g out.Concurrently(i, func() graphql.Marshaler { return rrm(innerCtx) }) - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} - -var externalExtensionImplementors = []string{"ExternalExtension", "_Entity"} - -func (ec *executionContext) _ExternalExtension(ctx context.Context, sel ast.SelectionSet, obj *gqlmodels.ExternalExtension) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, externalExtensionImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("ExternalExtension") - case "upc": - - out.Values[i] = ec._ExternalExtension_upc(ctx, field, obj) + case "_service": + field := field - if out.Values[i] == graphql.Null { - invalids++ + innerFunc := func(ctx context.Context) (res graphql.Marshaler) { + defer func() { + if r := recover(); r != nil { + ec.Error(ctx, ec.Recover(ctx, r)) + } + }() + res = ec._Query__service(ctx, field) + if res == graphql.Null { + atomic.AddUint32(&invalids, 1) + } + return res } - case "reviews": - - out.Values[i] = ec._ExternalExtension_reviews(ctx, field, obj) - - default: - panic("unknown field " + strconv.Quote(field.Name)) - } - } - out.Dispatch() - if invalids > 0 { - return graphql.Null - } - return out -} -var helloImplementors = []string{"Hello", "_Entity"} + rrm := func(ctx context.Context) graphql.Marshaler { + return ec.OperationContext.RootResolverMiddleware(ctx, innerFunc) + } -func (ec *executionContext) _Hello(ctx context.Context, sel ast.SelectionSet, obj *gqlmodels.Hello) graphql.Marshaler { - fields := graphql.CollectFields(ec.OperationContext, sel, helloImplementors) - out := graphql.NewFieldSet(fields) - var invalids uint32 - for i, field := range fields { - switch field.Name { - case "__typename": - out.Values[i] = graphql.MarshalString("Hello") - case "name": + out.Concurrently(i, func() graphql.Marshaler { + return rrm(innerCtx) + }) + case "__type": - out.Values[i] = ec._Hello_name(ctx, field, obj) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___type(ctx, field) + }) - if out.Values[i] == graphql.Null { - invalids++ - } - case "secondary": + case "__schema": - out.Values[i] = ec._Hello_secondary(ctx, field, obj) + out.Values[i] = ec.OperationContext.RootResolverMiddleware(innerCtx, func(ctx context.Context) (res graphql.Marshaler) { + return ec._Query___schema(ctx, field) + }) - if out.Values[i] == graphql.Null { - invalids++ - } default: panic("unknown field " + strconv.Quote(field.Name)) } @@ -3509,21 +3272,16 @@ func (ec *executionContext) marshalNBoolean2bool(ctx context.Context, sel ast.Se return res } -func (ec *executionContext) unmarshalNExternalExtensionByUpcsInput2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInput(ctx context.Context, v interface{}) (gqlmodels.ExternalExtensionByUpcsInput, error) { - res, err := ec.unmarshalInputExternalExtensionByUpcsInput(ctx, v) - return res, graphql.ErrorOnPath(ctx, err) -} - -func (ec *executionContext) unmarshalNExternalExtensionByUpcsInput2ᚕgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInputᚄ(ctx context.Context, v interface{}) ([]gqlmodels.ExternalExtensionByUpcsInput, error) { +func (ec *executionContext) unmarshalNCustomerByIDsInput2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomerByIDsInputᚄ(ctx context.Context, v interface{}) ([]*gqlmodels.CustomerByIDsInput, error) { var vSlice []interface{} if v != nil { vSlice = graphql.CoerceList(v) } var err error - res := make([]gqlmodels.ExternalExtensionByUpcsInput, len(vSlice)) + res := make([]*gqlmodels.CustomerByIDsInput, len(vSlice)) for i := range vSlice { ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) - res[i], err = ec.unmarshalNExternalExtensionByUpcsInput2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtensionByUpcsInput(ctx, vSlice[i]) + res[i], err = ec.unmarshalNCustomerByIDsInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomerByIDsInput(ctx, vSlice[i]) if err != nil { return nil, err } @@ -3531,18 +3289,56 @@ func (ec *executionContext) unmarshalNExternalExtensionByUpcsInput2ᚕgithubᚗc return res, nil } -func (ec *executionContext) marshalNHello2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v gqlmodels.Hello) graphql.Marshaler { - return ec._Hello(ctx, sel, &v) +func (ec *executionContext) unmarshalNCustomerByIDsInput2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomerByIDsInput(ctx context.Context, v interface{}) (*gqlmodels.CustomerByIDsInput, error) { + res, err := ec.unmarshalInputCustomerByIDsInput(ctx, v) + return &res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalNHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.Hello) graphql.Marshaler { - if v == nil { +func (ec *executionContext) unmarshalNID2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) + return res, graphql.ErrorOnPath(ctx, err) +} + +func (ec *executionContext) marshalNID2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) + if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") } - return graphql.Null } - return ec._Hello(ctx, sel, v) + return res +} + +func (ec *executionContext) unmarshalNID2ᚕstringᚄ(ctx context.Context, v interface{}) ([]string, error) { + var vSlice []interface{} + if v != nil { + vSlice = graphql.CoerceList(v) + } + var err error + res := make([]string, len(vSlice)) + for i := range vSlice { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithIndex(i)) + res[i], err = ec.unmarshalNID2string(ctx, vSlice[i]) + if err != nil { + return nil, err + } + } + return res, nil +} + +func (ec *executionContext) marshalNID2ᚕstringᚄ(ctx context.Context, sel ast.SelectionSet, v []string) graphql.Marshaler { + ret := make(graphql.Array, len(v)) + for i := range v { + ret[i] = ec.marshalNID2string(ctx, sel, v[i]) + } + + for _, e := range ret { + if e == graphql.Null { + return graphql.Null + } + } + + return ret } func (ec *executionContext) unmarshalNString2string(ctx context.Context, v interface{}) (string, error) { @@ -3651,13 +3447,14 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { - res, err := graphql.UnmarshalString(v) +func (ec *executionContext) unmarshalN_FieldSet2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfieldsetᚐFieldSet(ctx context.Context, v interface{}) (fieldset.FieldSet, error) { + tmp, err := graphql.UnmarshalString(v) + res := fieldset.FieldSet(tmp) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { - res := graphql.MarshalString(v) +func (ec *executionContext) marshalN_FieldSet2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfieldsetᚐFieldSet(ctx context.Context, sel ast.SelectionSet, v fieldset.FieldSet) graphql.Marshaler { + res := graphql.MarshalString(string(v)) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") @@ -3949,55 +3746,7 @@ func (ec *executionContext) marshalOBoolean2ᚖbool(ctx context.Context, sel ast return res } -func (ec *executionContext) marshalOExternalExtension2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx context.Context, sel ast.SelectionSet, v []*gqlmodels.ExternalExtension) graphql.Marshaler { - if v == nil { - return graphql.Null - } - ret := make(graphql.Array, len(v)) - var wg sync.WaitGroup - isLen1 := len(v) == 1 - if !isLen1 { - wg.Add(len(v)) - } - for i := range v { - i := i - fc := &graphql.FieldContext{ - Index: &i, - Result: &v[i], - } - 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 !isLen1 { - defer wg.Done() - } - ret[i] = ec.marshalOExternalExtension2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx, sel, v[i]) - } - if isLen1 { - f(i) - } else { - go f(i) - } - - } - wg.Wait() - - return ret -} - -func (ec *executionContext) marshalOExternalExtension2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐExternalExtension(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.ExternalExtension) graphql.Marshaler { - if v == nil { - return graphql.Null - } - return ec._ExternalExtension(ctx, sel, v) -} - -func (ec *executionContext) marshalOHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v []*gqlmodels.Hello) graphql.Marshaler { +func (ec *executionContext) marshalOCustomer2ᚕᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomer(ctx context.Context, sel ast.SelectionSet, v []*gqlmodels.Customer) graphql.Marshaler { if v == nil { return graphql.Null } @@ -4024,7 +3773,7 @@ func (ec *executionContext) marshalOHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlge if !isLen1 { defer wg.Done() } - ret[i] = ec.marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx, sel, v[i]) + ret[i] = ec.marshalOCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomer(ctx, sel, v[i]) } if isLen1 { f(i) @@ -4038,11 +3787,11 @@ func (ec *executionContext) marshalOHello2ᚕᚖgithubᚗcomᚋ99designsᚋgqlge return ret } -func (ec *executionContext) marshalOHello2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋtestdataᚋfederatedentityresolverᚋgqlmodelsᚐHello(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.Hello) graphql.Marshaler { +func (ec *executionContext) marshalOCustomer2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋ_examplesᚋfederationᚋmultiᚋinternalᚋgraphqlᚋgqlmodelsᚐCustomer(ctx context.Context, sel ast.SelectionSet, v *gqlmodels.Customer) graphql.Marshaler { if v == nil { return graphql.Null } - return ec._Hello(ctx, sel, v) + return ec._Customer(ctx, sel, v) } func (ec *executionContext) unmarshalOString2string(ctx context.Context, v interface{}) (string, error) { diff --git a/_examples/federation/multi/internal/graphql/gqlmodels/gqlmodels.go b/_examples/federation/multi/internal/graphql/gqlmodels/gqlmodels.go new file mode 100644 index 00000000000..38e2149a2a7 --- /dev/null +++ b/_examples/federation/multi/internal/graphql/gqlmodels/gqlmodels.go @@ -0,0 +1,14 @@ +// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. + +package gqlmodels + +type Customer struct { + ID string `json:"id"` + Name *string `json:"name,omitempty"` +} + +func (Customer) IsEntity() {} + +type CustomerByIDsInput struct { + ID string `json:"ID"` +} diff --git a/_examples/federation/multi/internal/graphql/resolvers/entity.resolvers.go b/_examples/federation/multi/internal/graphql/resolvers/entity.resolvers.go new file mode 100644 index 00000000000..e1f9199771f --- /dev/null +++ b/_examples/federation/multi/internal/graphql/resolvers/entity.resolvers.go @@ -0,0 +1,23 @@ +package resolvers + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.27-dev + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/generated" + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/gqlmodels" +) + +// FindManyCustomerByIDs is the resolver for the findManyCustomerByIDs field. +func (r *entityResolver) FindManyCustomerByIDs(ctx context.Context, reps []*gqlmodels.CustomerByIDsInput) ([]*gqlmodels.Customer, error) { + panic(fmt.Errorf("not implemented: FindManyCustomerByIDs - findManyCustomerByIDs")) +} + +// Entity returns generated.EntityResolver implementation. +func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } + +type entityResolver struct{ *Resolver } diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/resolver.go b/_examples/federation/multi/internal/graphql/resolvers/resolver.go similarity index 100% rename from plugin/federation/testdata/federatedentityresolver/resolvers/resolver.go rename to _examples/federation/multi/internal/graphql/resolvers/resolver.go diff --git a/_examples/federation/multi/internal/graphql/resolvers/schema.resolvers.go b/_examples/federation/multi/internal/graphql/resolvers/schema.resolvers.go new file mode 100644 index 00000000000..f66d5a9abde --- /dev/null +++ b/_examples/federation/multi/internal/graphql/resolvers/schema.resolvers.go @@ -0,0 +1,23 @@ +package resolvers + +// This file will be automatically regenerated based on the schema, any resolver implementations +// will be copied through when generating and any unknown code will be moved to the end. +// Code generated by github.com/99designs/gqlgen version v0.17.27-dev + +import ( + "context" + "fmt" + + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/generated" + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/gqlmodels" +) + +// Customers is the resolver for the customers field. +func (r *queryResolver) Customers(ctx context.Context, ids []string) ([]*gqlmodels.Customer, error) { + panic(fmt.Errorf("not implemented: Customers - customers")) +} + +// Query returns generated.QueryResolver implementation. +func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } + +type queryResolver struct{ *Resolver } diff --git a/_examples/federation/multi/internal/graphql/schema/schema.graphql b/_examples/federation/multi/internal/graphql/schema/schema.graphql new file mode 100644 index 00000000000..64b02d5aaa8 --- /dev/null +++ b/_examples/federation/multi/internal/graphql/schema/schema.graphql @@ -0,0 +1,10 @@ +directive @entityResolver(multi: Boolean) on OBJECT + +type Customer @key(fields: "id") @entityResolver(multi: true) { + id: ID! + name: String +} + +type Query { + customers(ids: [ID!]!): [Customer] +} diff --git a/_examples/federation/multi/server.go b/_examples/federation/multi/server.go new file mode 100644 index 00000000000..d9a3f0e4007 --- /dev/null +++ b/_examples/federation/multi/server.go @@ -0,0 +1,32 @@ +//go:generate go run ../../../testdata/gqlgen.go +package main + +import ( + "log" + "net/http" + "os" + + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/generated" + "github.com/99designs/gqlgen/_examples/federation/multi/internal/graphql/resolvers" + "github.com/99designs/gqlgen/graphql/handler" + "github.com/99designs/gqlgen/graphql/handler/debug" + "github.com/99designs/gqlgen/graphql/playground" +) + +const defaultPort = "4001" + +func main() { + port := os.Getenv("PORT") + if port == "" { + port = defaultPort + } + + srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &resolvers.Resolver{}})) + srv.Use(&debug.Tracer{}) + + http.Handle("/", playground.Handler("GraphQL playground", "/query")) + http.Handle("/query", srv) + + log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) + log.Fatal(http.ListenAndServe(":"+port, nil)) +} diff --git a/plugin/federation/federation_test.go b/plugin/federation/federation_test.go index b3b71869e0e..a0579f437d5 100644 --- a/plugin/federation/federation_test.go +++ b/plugin/federation/federation_test.go @@ -116,16 +116,6 @@ func TestCodeGeneration(t *testing.T) { require.NoError(t, f.GenerateCode(data)) } -func TestCodeGenerationFederation2SplitDir(t *testing.T) { - f, cfg := load(t, "testdata/federatedentityresolver/gqlgen.yml") - err := f.MutateConfig(cfg) - require.NoError(t, err) - data, err := codegen.BuildData(cfg) - require.NoError(t, err) - err = f.GenerateCode(data) - require.NoError(t, err) -} - func TestCodeGenerationFederation2(t *testing.T) { f, cfg := load(t, "testdata/federation2/federation2.yml") err := f.MutateConfig(cfg) diff --git a/plugin/federation/testdata/federatedentityresolver/gqlgen.yml b/plugin/federation/testdata/federatedentityresolver/gqlgen.yml deleted file mode 100644 index 35186fda7c8..00000000000 --- a/plugin/federation/testdata/federatedentityresolver/gqlgen.yml +++ /dev/null @@ -1,28 +0,0 @@ -schema: - - "testdata/federatedentityresolver/schema.graphql" -exec: - filename: testdata/federatedentityresolver/generated/exec.go - package: generated -federation: - filename: testdata/federatedentityresolver/generated/federation.go - package: generated - version: 2 -model: - filename: testdata/federatedentityresolver/gqlmodels/gqlmodels.go - package: gqlmodels -autobind: - - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" -resolver: - layout: follow-schema - dir: testdata/federatedentityresolver/resolvers - package: resolvers - filename_template: "{name}.resolvers.go" - -omit_slice_element_pointers: true - -models: - ID: - model: - - github.com/99designs/gqlgen/graphql.String - - github.com/99designs/gqlgen/graphql.Int - - github.com/99designs/gqlgen/graphql.ID diff --git a/plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go b/plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go deleted file mode 100644 index 45c94681df3..00000000000 --- a/plugin/federation/testdata/federatedentityresolver/gqlmodels/fieldset.go +++ /dev/null @@ -1,3 +0,0 @@ -package gqlmodels - -type _FieldSet string //nolint:deadcode,unused diff --git a/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go b/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go deleted file mode 100644 index e9df746ec22..00000000000 --- a/plugin/federation/testdata/federatedentityresolver/gqlmodels/gqlmodels.go +++ /dev/null @@ -1,21 +0,0 @@ -// Code generated by github.com/99designs/gqlgen, DO NOT EDIT. - -package gqlmodels - -type ExternalExtension struct { - Upc string `json:"upc"` - Reviews []*Hello `json:"reviews,omitempty"` -} - -func (ExternalExtension) IsEntity() {} - -type ExternalExtensionByUpcsInput struct { - Upc string `json:"Upc"` -} - -type Hello struct { - Name string `json:"name"` - Secondary string `json:"secondary"` -} - -func (Hello) IsEntity() {} diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go b/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go deleted file mode 100644 index e49859333a0..00000000000 --- a/plugin/federation/testdata/federatedentityresolver/resolvers/entity.resolvers.go +++ /dev/null @@ -1,28 +0,0 @@ -package resolvers - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.27-dev - -import ( - "context" - "fmt" - - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/generated" - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" -) - -// FindManyExternalExtensionByUpcs is the resolver for the findManyExternalExtensionByUpcs field. -func (r *entityResolver) FindManyExternalExtensionByUpcs(ctx context.Context, reps []gqlmodels.ExternalExtensionByUpcsInput) ([]*gqlmodels.ExternalExtension, error) { - panic(fmt.Errorf("not implemented: FindManyExternalExtensionByUpcs - findManyExternalExtensionByUpcs")) -} - -// FindHelloByName is the resolver for the findHelloByName field. -func (r *entityResolver) FindHelloByName(ctx context.Context, name string) (*gqlmodels.Hello, error) { - panic(fmt.Errorf("not implemented: FindHelloByName - findHelloByName")) -} - -// Entity returns generated.EntityResolver implementation. -func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } - -type entityResolver struct{ *Resolver } diff --git a/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go b/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go deleted file mode 100644 index eda0ab8856c..00000000000 --- a/plugin/federation/testdata/federatedentityresolver/resolvers/schema.resolvers.go +++ /dev/null @@ -1,23 +0,0 @@ -package resolvers - -// This file will be automatically regenerated based on the schema, any resolver implementations -// will be copied through when generating and any unknown code will be moved to the end. -// Code generated by github.com/99designs/gqlgen version v0.17.27-dev - -import ( - "context" - "fmt" - - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/generated" - "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/gqlmodels" -) - -// Hello is the resolver for the hello field. -func (r *customQueryResolver) Hello(ctx context.Context) (*gqlmodels.Hello, error) { - panic(fmt.Errorf("not implemented: Hello - hello")) -} - -// CustomQuery returns generated.CustomQueryResolver implementation. -func (r *Resolver) CustomQuery() generated.CustomQueryResolver { return &customQueryResolver{r} } - -type customQueryResolver struct{ *Resolver } diff --git a/plugin/federation/testdata/federatedentityresolver/schema.graphql b/plugin/federation/testdata/federatedentityresolver/schema.graphql deleted file mode 100644 index e07c02c238a..00000000000 --- a/plugin/federation/testdata/federatedentityresolver/schema.graphql +++ /dev/null @@ -1,34 +0,0 @@ -extend schema - @link( - url: "https://specs.apollo.dev/federation/v2.0" - import: [ - "@key" - "@shareable" - "@provides" - "@external" - "@tag" - "@extends" - "@override" - "@inaccessible" - ] - ) - -schema { - query: CustomQuery -} - -directive @entityResolver(multi: Boolean) on OBJECT - -type Hello @key(fields: "name") { - name: String! - secondary: String! -} - -extend type ExternalExtension @key(fields: "upc") @entityResolver(multi: true) { - upc: String! - reviews: [Hello] -} - -type CustomQuery { - hello: Hello -} diff --git a/plugin/federation/v2federation_entityresolver_test.go b/plugin/federation/v2federation_entityresolver_test.go deleted file mode 100644 index d08ff6d5230..00000000000 --- a/plugin/federation/v2federation_entityresolver_test.go +++ /dev/null @@ -1,92 +0,0 @@ -//go:generate go run ../../testdata/gqlgen.go -config testdata/federatedentityresolver/gqlgen.yml -package federation - -// import ( -// "strconv" -// "testing" - -// "github.com/99designs/gqlgen/client" -// "github.com/99designs/gqlgen/graphql/handler" -// "github.com/stretchr/testify/require" - -// "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/generated" -// "github.com/99designs/gqlgen/plugin/federation/testdata/federatedentityresolver/resolvers" -// ) - -// func TestFederatedEntityResolver(t *testing.T) { -// c := client.New(handler.NewDefaultServer( -// generated.NewExecutableSchema(generated.Config{ -// Resolvers: &resolvers.Resolver{}, -// }), -// )) - -// t.Run("Hello entities", func(t *testing.T) { -// representations := []map[string]interface{}{ -// { -// "__typename": "Hello", -// "name": "first name - 1", -// }, { -// "__typename": "Hello", -// "name": "first name - 2", -// }, -// } - -// var resp struct { -// Entities []struct { -// Name string `json:"name"` -// } `json:"_entities"` -// } - -// err := c.Post( -// entityQuery([]string{ -// "Hello {name}", -// }), -// &resp, -// client.Var("representations", representations), -// ) - -// require.NoError(t, err) -// require.Equal(t, resp.Entities[0].Name, "first name - 1") -// require.Equal(t, resp.Entities[1].Name, "first name - 2") -// }) -// } - -// func TestFederatedMultiEntityResolver(t *testing.T) { -// c := client.New(handler.NewDefaultServer( -// generated.NewExecutableSchema(generated.Config{ -// Resolvers: &resolvers.Resolver{}, -// }), -// )) - -// t.Run("MultiHello entities", func(t *testing.T) { -// itemCount := 10 -// representations := []map[string]interface{}{} - -// for i := 0; i < itemCount; i++ { -// representations = append(representations, map[string]interface{}{ -// "__typename": "MultiHello", -// "name": "world name - " + strconv.Itoa(i), -// }) -// } - -// var resp struct { -// Entities []struct { -// Name string `json:"name"` -// } `json:"_entities"` -// } - -// err := c.Post( -// entityQuery([]string{ -// "MultiHello {name}", -// }), -// &resp, -// client.Var("representations", representations), -// ) - -// require.NoError(t, err) - -// for i := 0; i < itemCount; i++ { -// require.Equal(t, resp.Entities[i].Name, "world name - "+strconv.Itoa(i)+" - from multiget") -// } -// }) -// } From 89953d20d31d487f9edda6b9e2e904ede13a9a61 Mon Sep 17 00:00:00 2001 From: Joseph Lyons Date: Mon, 27 Mar 2023 16:46:17 +1100 Subject: [PATCH 4/4] Remove unused model and FieldSet type --- .../internal/graphql/generated/generated.go | 10 ++++----- .../test_data/gqlmodels/federation.go | 22 ------------------- 2 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 plugin/federation/test_data/gqlmodels/federation.go diff --git a/_examples/federation/multi/internal/graphql/generated/generated.go b/_examples/federation/multi/internal/graphql/generated/generated.go index a6b94641997..ec6c2e61467 100644 --- a/_examples/federation/multi/internal/graphql/generated/generated.go +++ b/_examples/federation/multi/internal/graphql/generated/generated.go @@ -15,7 +15,6 @@ import ( "github.com/99designs/gqlgen/graphql" "github.com/99designs/gqlgen/graphql/introspection" "github.com/99designs/gqlgen/plugin/federation/fedruntime" - "github.com/99designs/gqlgen/plugin/federation/fieldset" gqlparser "github.com/vektah/gqlparser/v2" "github.com/vektah/gqlparser/v2/ast" ) @@ -3447,14 +3446,13 @@ func (ec *executionContext) marshalN_Entity2ᚕgithubᚗcomᚋ99designsᚋgqlgen return ret } -func (ec *executionContext) unmarshalN_FieldSet2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfieldsetᚐFieldSet(ctx context.Context, v interface{}) (fieldset.FieldSet, error) { - tmp, err := graphql.UnmarshalString(v) - res := fieldset.FieldSet(tmp) +func (ec *executionContext) unmarshalN_FieldSet2string(ctx context.Context, v interface{}) (string, error) { + res, err := graphql.UnmarshalString(v) return res, graphql.ErrorOnPath(ctx, err) } -func (ec *executionContext) marshalN_FieldSet2githubᚗcomᚋ99designsᚋgqlgenᚋpluginᚋfederationᚋfieldsetᚐFieldSet(ctx context.Context, sel ast.SelectionSet, v fieldset.FieldSet) graphql.Marshaler { - res := graphql.MarshalString(string(v)) +func (ec *executionContext) marshalN_FieldSet2string(ctx context.Context, sel ast.SelectionSet, v string) graphql.Marshaler { + res := graphql.MarshalString(v) if res == graphql.Null { if !graphql.HasFieldError(ctx, graphql.GetFieldContext(ctx)) { ec.Errorf(ctx, "the requested element is null which the schema does not allow") diff --git a/plugin/federation/test_data/gqlmodels/federation.go b/plugin/federation/test_data/gqlmodels/federation.go deleted file mode 100644 index 98b47464803..00000000000 --- a/plugin/federation/test_data/gqlmodels/federation.go +++ /dev/null @@ -1,22 +0,0 @@ -package model - -type _FieldSet string //nolint:deadcode,unused - -type Hello struct { - Name string - Secondary string -} - -func (Hello) IsEntity() {} - -type ExternalExtensionByUpcsInput struct { - Upc string -} - -func (ExternalExtensionByUpcsInput) IsEntity() {} - -type ExternalExtension struct { - Upc string -} - -func (ExternalExtension) IsEntity() {}