diff --git a/go.mod b/go.mod index 141c03e3a37..c18b163274e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/99designs/gqlgen +module github.com/geneva/gqlgen go 1.18 diff --git a/plugin/federation/federation.go b/plugin/federation/federation.go index 10f94c152e6..9371e727f9a 100644 --- a/plugin/federation/federation.go +++ b/plugin/federation/federation.go @@ -72,9 +72,6 @@ func (f *federation) MutateConfig(cfg *config.Config) error { cfg.Directives["provides"] = config.DirectiveConfig{SkipRuntime: true} cfg.Directives["key"] = config.DirectiveConfig{SkipRuntime: true} cfg.Directives["extends"] = config.DirectiveConfig{SkipRuntime: true} - cfg.Directives["entityResolver"] = config.DirectiveConfig{SkipRuntime: true} - cfg.Directives["interfaceObject"] = config.DirectiveConfig{SkipRuntime: true} - cfg.Directives["composeDirective"] = config.DirectiveConfig{SkipRuntime: true} // Federation 2 specific directives if f.Version == 2 { @@ -83,6 +80,9 @@ func (f *federation) MutateConfig(cfg *config.Config) error { cfg.Directives["tag"] = config.DirectiveConfig{SkipRuntime: true} cfg.Directives["override"] = config.DirectiveConfig{SkipRuntime: true} cfg.Directives["inaccessible"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["entityResolver"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["interfaceObject"] = config.DirectiveConfig{SkipRuntime: true} + cfg.Directives["composeDirective"] = config.DirectiveConfig{SkipRuntime: true} } return nil diff --git a/plugin/federation/testdata/entityresolver/generated/exec.go b/plugin/federation/testdata/entityresolver/generated/exec.go index b7194d987c6..0b1e4a60ab7 100644 --- a/plugin/federation/testdata/entityresolver/generated/exec.go +++ b/plugin/federation/testdata/entityresolver/generated/exec.go @@ -41,6 +41,7 @@ type ResolverRoot interface { } type DirectiveRoot struct { + EntityResolver func(ctx context.Context, obj interface{}, next graphql.Resolver, multi *bool) (res interface{}, err error) } type ComplexityRoot struct { @@ -867,6 +868,21 @@ var parsedSchema = gqlparser.MustLoadSchema(sources...) // 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_Entity_findHelloByName_args(ctx context.Context, rawArgs map[string]interface{}) (map[string]interface{}, error) { var err error args := map[string]interface{}{} @@ -1381,8 +1397,32 @@ func (ec *executionContext) _Entity_findManyMultiHelloByNames(ctx context.Contex } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindManyMultiHelloByNames(rctx, fc.Args["reps"].([]*model.MultiHelloByNamesInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyMultiHelloByNames(rctx, fc.Args["reps"].([]*model.MultiHelloByNamesInput)) + } + 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.([]*model.MultiHello); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHello`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -1437,8 +1477,32 @@ func (ec *executionContext) _Entity_findManyMultiHelloMultipleRequiresByNames(ct } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(rctx, fc.Args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyMultiHelloMultipleRequiresByNames(rctx, fc.Args["reps"].([]*model.MultiHelloMultipleRequiresByNamesInput)) + } + 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.([]*model.MultiHelloMultipleRequires); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHelloMultipleRequires`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -1499,8 +1563,32 @@ func (ec *executionContext) _Entity_findManyMultiHelloRequiresByNames(ctx contex } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindManyMultiHelloRequiresByNames(rctx, fc.Args["reps"].([]*model.MultiHelloRequiresByNamesInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyMultiHelloRequiresByNames(rctx, fc.Args["reps"].([]*model.MultiHelloRequiresByNamesInput)) + } + 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.([]*model.MultiHelloRequires); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHelloRequires`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -1559,8 +1647,32 @@ func (ec *executionContext) _Entity_findManyMultiHelloWithErrorByNames(ctx conte } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindManyMultiHelloWithErrorByNames(rctx, fc.Args["reps"].([]*model.MultiHelloWithErrorByNamesInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyMultiHelloWithErrorByNames(rctx, fc.Args["reps"].([]*model.MultiHelloWithErrorByNamesInput)) + } + 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.([]*model.MultiHelloWithError); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiHelloWithError`, tmp) }) if err != nil { ec.Error(ctx, err) @@ -1615,8 +1727,32 @@ func (ec *executionContext) _Entity_findManyMultiPlanetRequiresNestedByNames(ctx } }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { - ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(rctx, fc.Args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput)) + directive0 := func(rctx context.Context) (interface{}, error) { + ctx = rctx // use context from middleware stack in children + return ec.resolvers.Entity().FindManyMultiPlanetRequiresNestedByNames(rctx, fc.Args["reps"].([]*model.MultiPlanetRequiresNestedByNamesInput)) + } + 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.([]*model.MultiPlanetRequiresNested); ok { + return data, nil + } + return nil, fmt.Errorf(`unexpected type %T from directive, should be []*github.com/99designs/gqlgen/plugin/federation/testdata/entityresolver/generated/model.MultiPlanetRequiresNested`, tmp) }) if err != nil { ec.Error(ctx, err)