diff --git a/_examples/federation/accounts/gqlgen.yml b/_examples/federation/accounts/gqlgen.yml index 417fc52b96e..cdf18e91f1b 100644 --- a/_examples/federation/accounts/gqlgen.yml +++ b/_examples/federation/accounts/gqlgen.yml @@ -4,12 +4,12 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph # Where should any generated models go? model: diff --git a/_examples/federation/accounts/graph/entity.resolvers.go b/_examples/federation/accounts/graph/entity.resolvers.go index 5768e8a65f3..49c0d51f010 100644 --- a/_examples/federation/accounts/graph/entity.resolvers.go +++ b/_examples/federation/accounts/graph/entity.resolvers.go @@ -6,7 +6,6 @@ package graph import ( "context" - "github.com/99designs/gqlgen/_examples/federation/accounts/graph/generated" "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" ) @@ -31,7 +30,7 @@ func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.Us }, nil } -// Entity returns generated.EntityResolver implementation. -func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } +// Entity returns EntityResolver implementation. +func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } type entityResolver struct{ *Resolver } diff --git a/_examples/federation/accounts/graph/generated/federation.go b/_examples/federation/accounts/graph/federation.go similarity index 99% rename from _examples/federation/accounts/graph/generated/federation.go rename to _examples/federation/accounts/graph/federation.go index 5c21a55acb2..1a3f794acb3 100644 --- a/_examples/federation/accounts/graph/generated/federation.go +++ b/_examples/federation/accounts/graph/federation.go @@ -1,6 +1,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "context" diff --git a/_examples/federation/accounts/graph/generated/generated.go b/_examples/federation/accounts/graph/generated.go similarity index 98% rename from _examples/federation/accounts/graph/generated/generated.go rename to _examples/federation/accounts/graph/generated.go index 666f381ad08..01b8fde71d7 100644 --- a/_examples/federation/accounts/graph/generated/generated.go +++ b/_examples/federation/accounts/graph/generated.go @@ -1,10 +1,11 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "bytes" "context" + "embed" "errors" "fmt" "strconv" @@ -74,8 +75,8 @@ type ComplexityRoot struct { } type EntityResolver interface { - FindEmailHostByID(ctx context.Context, id string) (*model.EmailHost, error) - FindUserByID(ctx context.Context, id string) (*model.User, error) + FindEmailHostByID(ctx context.Context, obj fedruntime.Entity, id string) (*model.EmailHost, error) + FindUserByID(ctx context.Context, obj fedruntime.Entity, id string) (*model.User, error) } type QueryResolver interface { Me(ctx context.Context) (*model.User, error) @@ -246,24 +247,20 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -var sources = []*ast.Source{ - {Name: "../schema.graphqls", Input: `extend type Query { - me: User -} +//go:embed "schema.graphqls" +var sourcesFS embed.FS -type EmailHost @key(fields: "id") { - id: String! - name: String! +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) } -type User @key(fields: "id") { - id: ID! - host: EmailHost! - email: String! - username: String! -} -`, BuiltIn: false}, - {Name: "../../federation/directives.graphql", Input: ` +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` scalar _Any scalar _FieldSet @@ -274,7 +271,7 @@ type User @key(fields: "id") { directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE `, BuiltIn: true}, - {Name: "../../federation/entity.graphql", Input: ` + {Name: "../federation/entity.graphql", Input: ` # a union of all types that use the @key directive union _Entity = EmailHost | User @@ -487,7 +484,7 @@ func (ec *executionContext) fieldContext_EmailHost_name(ctx context.Context, fie return fc, nil } -func (ec *executionContext) _Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Entity_findEmailHostByID(ctx context.Context, field graphql.CollectedField, obj fedruntime.Entity) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Entity_findEmailHostByID(ctx, field) if err != nil { return graphql.Null @@ -501,7 +498,7 @@ func (ec *executionContext) _Entity_findEmailHostByID(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindEmailHostByID(rctx, fc.Args["id"].(string)) + return ec.resolvers.Entity().FindEmailHostByID(rctx, obj, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -548,7 +545,7 @@ func (ec *executionContext) fieldContext_Entity_findEmailHostByID(ctx context.Co return fc, nil } -func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField) (ret graphql.Marshaler) { +func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field graphql.CollectedField, obj fedruntime.Entity) (ret graphql.Marshaler) { fc, err := ec.fieldContext_Entity_findUserByID(ctx, field) if err != nil { return graphql.Null @@ -562,7 +559,7 @@ func (ec *executionContext) _Entity_findUserByID(ctx context.Context, field grap }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Entity().FindUserByID(rctx, fc.Args["id"].(string)) + return ec.resolvers.Entity().FindUserByID(rctx, obj, fc.Args["id"].(string)) }) if err != nil { ec.Error(ctx, err) @@ -2960,20 +2957,11 @@ func (ec *executionContext) _EmailHost(ctx context.Context, sel ast.SelectionSet var entityImplementors = []string{"Entity"} -func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) graphql.Marshaler { +func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet, obj fedruntime.Entity) graphql.Marshaler { fields := graphql.CollectFields(ec.OperationContext, sel, entityImplementors) - ctx = graphql.WithFieldContext(ctx, &graphql.FieldContext{ - Object: "Entity", - }) - out := graphql.NewFieldSet(fields) var invalids uint32 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") @@ -2986,19 +2974,16 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Entity_findEmailHostByID(ctx, field) + res = ec._Entity_findEmailHostByID(ctx, field, obj) 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) + return innerFunc(ctx) + }) case "findUserByID": field := field @@ -3009,19 +2994,16 @@ func (ec *executionContext) _Entity(ctx context.Context, sel ast.SelectionSet) g ec.Error(ctx, ec.Recover(ctx, r)) } }() - res = ec._Entity_findUserByID(ctx, field) + res = ec._Entity_findUserByID(ctx, field, obj) 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) + return innerFunc(ctx) + }) default: panic("unknown field " + strconv.Quote(field.Name)) diff --git a/_examples/federation/accounts/graph/schema.resolvers.go b/_examples/federation/accounts/graph/schema.resolvers.go index 34298d54f40..c86ff1ed497 100644 --- a/_examples/federation/accounts/graph/schema.resolvers.go +++ b/_examples/federation/accounts/graph/schema.resolvers.go @@ -6,7 +6,6 @@ package graph import ( "context" - "github.com/99designs/gqlgen/_examples/federation/accounts/graph/generated" "github.com/99designs/gqlgen/_examples/federation/accounts/graph/model" ) @@ -23,7 +22,7 @@ func (r *queryResolver) Me(ctx context.Context) (*model.User, error) { }, nil } -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } diff --git a/_examples/federation/accounts/server.go b/_examples/federation/accounts/server.go index dbbc5070de5..68ced60c099 100644 --- a/_examples/federation/accounts/server.go +++ b/_examples/federation/accounts/server.go @@ -7,7 +7,6 @@ import ( "os" "github.com/99designs/gqlgen/_examples/federation/accounts/graph" - "github.com/99designs/gqlgen/_examples/federation/accounts/graph/generated" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/debug" "github.com/99designs/gqlgen/graphql/playground" @@ -21,7 +20,7 @@ func main() { port = defaultPort } - srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) + srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) srv.Use(&debug.Tracer{}) http.Handle("/", playground.Handler("GraphQL playground", "/query")) diff --git a/_examples/federation/products/gqlgen.yml b/_examples/federation/products/gqlgen.yml index fc8ab5be506..171115c6cd1 100644 --- a/_examples/federation/products/gqlgen.yml +++ b/_examples/federation/products/gqlgen.yml @@ -4,12 +4,12 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph # Where should any generated models go? model: diff --git a/_examples/federation/products/graph/entity.resolvers.go b/_examples/federation/products/graph/entity.resolvers.go index 979867d29a7..876288a0047 100644 --- a/_examples/federation/products/graph/entity.resolvers.go +++ b/_examples/federation/products/graph/entity.resolvers.go @@ -6,7 +6,6 @@ package graph import ( "context" - "github.com/99designs/gqlgen/_examples/federation/products/graph/generated" "github.com/99designs/gqlgen/_examples/federation/products/graph/model" ) @@ -38,7 +37,7 @@ func (r *entityResolver) FindProductByUpc(ctx context.Context, upc string) (*mod return nil, nil } -// Entity returns generated.EntityResolver implementation. -func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } +// Entity returns EntityResolver implementation. +func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } type entityResolver struct{ *Resolver } diff --git a/_examples/federation/products/graph/generated/federation.go b/_examples/federation/products/graph/federation.go similarity index 99% rename from _examples/federation/products/graph/generated/federation.go rename to _examples/federation/products/graph/federation.go index aa76fede75a..151472bfcc4 100644 --- a/_examples/federation/products/graph/generated/federation.go +++ b/_examples/federation/products/graph/federation.go @@ -1,6 +1,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "context" diff --git a/_examples/federation/products/graph/generated/generated.go b/_examples/federation/products/graph/generated.go similarity index 99% rename from _examples/federation/products/graph/generated/generated.go rename to _examples/federation/products/graph/generated.go index d1ed696ca44..e056e53c7e5 100644 --- a/_examples/federation/products/graph/generated/generated.go +++ b/_examples/federation/products/graph/generated.go @@ -1,10 +1,11 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "bytes" "context" + "embed" "errors" "fmt" "strconv" @@ -273,25 +274,20 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -var sources = []*ast.Source{ - {Name: "../schema.graphqls", Input: `extend type Query { - topProducts(first: Int = 5): [Product] -} +//go:embed "schema.graphqls" +var sourcesFS embed.FS -type Manufacturer @key(fields: "id") { - id: String! - name: String! +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) } -type Product @key(fields: "manufacturer { id } id") @key(fields: "upc") { - id: String! - manufacturer: Manufacturer! - upc: String! - name: String! - price: Int! -} -`, BuiltIn: false}, - {Name: "../../federation/directives.graphql", Input: ` +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` scalar _Any scalar _FieldSet @@ -302,7 +298,7 @@ type Product @key(fields: "manufacturer { id } id") @key(fields: "upc") { directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE `, BuiltIn: true}, - {Name: "../../federation/entity.graphql", Input: ` + {Name: "../federation/entity.graphql", Input: ` # a union of all types that use the @key directive union _Entity = Manufacturer | Product diff --git a/_examples/federation/products/graph/schema.resolvers.go b/_examples/federation/products/graph/schema.resolvers.go index f53bc084344..d3776f57456 100644 --- a/_examples/federation/products/graph/schema.resolvers.go +++ b/_examples/federation/products/graph/schema.resolvers.go @@ -6,7 +6,6 @@ package graph import ( "context" - "github.com/99designs/gqlgen/_examples/federation/products/graph/generated" "github.com/99designs/gqlgen/_examples/federation/products/graph/model" ) @@ -15,7 +14,7 @@ func (r *queryResolver) TopProducts(ctx context.Context, first *int) ([]*model.P return hats, nil } -// Query returns generated.QueryResolver implementation. -func (r *Resolver) Query() generated.QueryResolver { return &queryResolver{r} } +// Query returns QueryResolver implementation. +func (r *Resolver) Query() QueryResolver { return &queryResolver{r} } type queryResolver struct{ *Resolver } diff --git a/_examples/federation/products/server.go b/_examples/federation/products/server.go index df80eceab1c..202aea9f79c 100644 --- a/_examples/federation/products/server.go +++ b/_examples/federation/products/server.go @@ -7,7 +7,6 @@ import ( "os" "github.com/99designs/gqlgen/_examples/federation/products/graph" - "github.com/99designs/gqlgen/_examples/federation/products/graph/generated" "github.com/99designs/gqlgen/graphql/handler" "github.com/99designs/gqlgen/graphql/handler/debug" "github.com/99designs/gqlgen/graphql/playground" @@ -21,7 +20,7 @@ func main() { port = defaultPort } - srv := handler.NewDefaultServer(generated.NewExecutableSchema(generated.Config{Resolvers: &graph.Resolver{}})) + srv := handler.NewDefaultServer(graph.NewExecutableSchema(graph.Config{Resolvers: &graph.Resolver{}})) srv.Use(&debug.Tracer{}) http.Handle("/", playground.Handler("GraphQL playground", "/query")) diff --git a/_examples/federation/reviews/gqlgen.yml b/_examples/federation/reviews/gqlgen.yml index 23346d30895..e2474baa827 100644 --- a/_examples/federation/reviews/gqlgen.yml +++ b/_examples/federation/reviews/gqlgen.yml @@ -4,12 +4,12 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph # Where should any generated models go? model: diff --git a/_examples/federation/reviews/graph/entity.resolvers.go b/_examples/federation/reviews/graph/entity.resolvers.go index 03a4f3196e2..cc0612d9b1a 100644 --- a/_examples/federation/reviews/graph/entity.resolvers.go +++ b/_examples/federation/reviews/graph/entity.resolvers.go @@ -6,7 +6,6 @@ package graph import ( "context" - "github.com/99designs/gqlgen/_examples/federation/reviews/graph/generated" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" ) @@ -36,7 +35,7 @@ func (r *entityResolver) FindUserByID(ctx context.Context, id string) (*model.Us }, nil } -// Entity returns generated.EntityResolver implementation. -func (r *Resolver) Entity() generated.EntityResolver { return &entityResolver{r} } +// Entity returns EntityResolver implementation. +func (r *Resolver) Entity() EntityResolver { return &entityResolver{r} } type entityResolver struct{ *Resolver } diff --git a/_examples/federation/reviews/graph/generated/federation.go b/_examples/federation/reviews/graph/federation.go similarity index 99% rename from _examples/federation/reviews/graph/generated/federation.go rename to _examples/federation/reviews/graph/federation.go index ad8aedf59e4..d67dd3f52d9 100644 --- a/_examples/federation/reviews/graph/generated/federation.go +++ b/_examples/federation/reviews/graph/federation.go @@ -1,6 +1,6 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "context" diff --git a/_examples/federation/reviews/graph/generated/generated.go b/_examples/federation/reviews/graph/generated.go similarity index 99% rename from _examples/federation/reviews/graph/generated/generated.go rename to _examples/federation/reviews/graph/generated.go index c1ca3d0e63f..71fa9bf2c00 100644 --- a/_examples/federation/reviews/graph/generated/generated.go +++ b/_examples/federation/reviews/graph/generated.go @@ -1,10 +1,11 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "bytes" "context" + "embed" "errors" "fmt" "strconv" @@ -295,35 +296,20 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -var sources = []*ast.Source{ - {Name: "../schema.graphqls", Input: `type Review { - body: String! - author: User! @provides(fields: "username") - product: Product! -} - -extend type EmailHost @key(fields: "id") { - id: String! @external -} - -extend type User @key(fields: "id") { - id: ID! @external - host: EmailHost! @external - email: String! @external - reviews: [Review] @requires(fields: "host {id} email") -} +//go:embed "schema.graphqls" +var sourcesFS embed.FS -extend type Manufacturer @key(fields: "id") { - id: String! @external +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) } -extend type Product @key(fields: " manufacturer{ id} id") { - id: String! @external - manufacturer: Manufacturer! @external - reviews: [Review] -} -`, BuiltIn: false}, - {Name: "../../federation/directives.graphql", Input: ` +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, + {Name: "../federation/directives.graphql", Input: ` scalar _Any scalar _FieldSet @@ -334,7 +320,7 @@ extend type Product @key(fields: " manufacturer{ id} id") { directive @key(fields: _FieldSet!) repeatable on OBJECT | INTERFACE `, BuiltIn: true}, - {Name: "../../federation/entity.graphql", Input: ` + {Name: "../federation/entity.graphql", Input: ` # a union of all types that use the @key directive union _Entity = EmailHost | Manufacturer | Product | User diff --git a/_examples/federation/reviews/graph/schema.resolvers.go b/_examples/federation/reviews/graph/schema.resolvers.go index 824eb6d51cf..2f652f858b5 100644 --- a/_examples/federation/reviews/graph/schema.resolvers.go +++ b/_examples/federation/reviews/graph/schema.resolvers.go @@ -6,7 +6,6 @@ package graph import ( "context" - "github.com/99designs/gqlgen/_examples/federation/reviews/graph/generated" "github.com/99designs/gqlgen/_examples/federation/reviews/graph/model" ) @@ -21,7 +20,7 @@ func (r *userResolver) Reviews(ctx context.Context, obj *model.User) ([]*model.R return productReviews, nil } -// User returns generated.UserResolver implementation. -func (r *Resolver) User() generated.UserResolver { return &userResolver{r} } +// User returns UserResolver implementation. +func (r *Resolver) User() UserResolver { return &userResolver{r} } type userResolver struct{ *Resolver } diff --git a/_examples/websocket-initfunc/server/gqlgen.yml b/_examples/websocket-initfunc/server/gqlgen.yml index c78f6a91f86..fc31899ba25 100644 --- a/_examples/websocket-initfunc/server/gqlgen.yml +++ b/_examples/websocket-initfunc/server/gqlgen.yml @@ -4,13 +4,13 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph # Uncomment to enable federation # federation: -# filename: graph/generated/federation.go -# package: generated +# filename: graph/federation.go +# package: graph # Where should any generated models go? model: diff --git a/_examples/websocket-initfunc/server/graph/generated/generated.go b/_examples/websocket-initfunc/server/graph/generated.go similarity index 99% rename from _examples/websocket-initfunc/server/graph/generated/generated.go rename to _examples/websocket-initfunc/server/graph/generated.go index a9ac25741c2..db386d62c9f 100644 --- a/_examples/websocket-initfunc/server/graph/generated/generated.go +++ b/_examples/websocket-initfunc/server/graph/generated.go @@ -1,10 +1,11 @@ // Code generated by github.com/99designs/gqlgen, DO NOT EDIT. -package generated +package graph import ( "bytes" "context" + "embed" "errors" "fmt" "io" @@ -212,24 +213,19 @@ func (ec *executionContext) introspectType(name string) (*introspection.Type, er return introspection.WrapTypeFromDef(parsedSchema, parsedSchema.Types[name]), nil } -var sources = []*ast.Source{ - {Name: "../schema.graphqls", Input: `# GraphQL schema example -# - -type Dummy { - id: ID! - text: String! - done: Boolean! -} +//go:embed "schema.graphqls" +var sourcesFS embed.FS -type Mutation { - postMessageTo(subscriber: String!, content: String!): ID! +func sourceData(filename string) string { + data, err := sourcesFS.ReadFile(filename) + if err != nil { + panic(fmt.Sprintf("codegen problem: %s not available", filename)) + } + return string(data) } -type Subscription { - subscribe(subscriber: String!): String! -} -`, BuiltIn: false}, +var sources = []*ast.Source{ + {Name: "schema.graphqls", Input: sourceData("schema.graphqls"), BuiltIn: false}, } var parsedSchema = gqlparser.MustLoadSchema(sources...) diff --git a/_examples/websocket-initfunc/server/graph/schema.resolvers.go b/_examples/websocket-initfunc/server/graph/schema.resolvers.go index dbf34d64695..fc9061cf437 100644 --- a/_examples/websocket-initfunc/server/graph/schema.resolvers.go +++ b/_examples/websocket-initfunc/server/graph/schema.resolvers.go @@ -6,8 +6,6 @@ package graph import ( "context" "fmt" - - "github.com/gqlgen/_examples/websocket-initfunc/server/graph/generated" ) // PostMessageTo is the resolver for the postMessageTo field. @@ -20,11 +18,11 @@ func (r *subscriptionResolver) Subscribe(ctx context.Context, subscriber string) panic(fmt.Errorf("not implemented")) } -// Mutation returns generated.MutationResolver implementation. -func (r *Resolver) Mutation() generated.MutationResolver { return &mutationResolver{r} } +// Mutation returns MutationResolver implementation. +func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} } -// Subscription returns generated.SubscriptionResolver implementation. -func (r *Resolver) Subscription() generated.SubscriptionResolver { return &subscriptionResolver{r} } +// Subscription returns SubscriptionResolver implementation. +func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} } type mutationResolver struct{ *Resolver } type subscriptionResolver struct{ *Resolver } diff --git a/api/testdata/default/gqlgen.yml b/api/testdata/default/gqlgen.yml index 56f2239b960..964a9eba97d 100644 --- a/api/testdata/default/gqlgen.yml +++ b/api/testdata/default/gqlgen.yml @@ -4,13 +4,13 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph # Uncomment to enable federation # federation: -# filename: graph/generated/federation.go -# package: generated +# filename: graph/federation.go +# package: graph # Where should any generated models go? model: diff --git a/api/testdata/federation2/gqlgen.yml b/api/testdata/federation2/gqlgen.yml index 8dc5d538636..a93567abf4b 100644 --- a/api/testdata/federation2/gqlgen.yml +++ b/api/testdata/federation2/gqlgen.yml @@ -4,13 +4,13 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph # Uncomment to enable federation federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph # Where should any generated models go? model: diff --git a/docs/content/config.md b/docs/content/config.md index a274947d56e..81e912361f8 100644 --- a/docs/content/config.md +++ b/docs/content/config.md @@ -23,8 +23,8 @@ exec: # Enable Apollo federation support federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph # Where should any generated models go? model: diff --git a/docs/content/recipes/federation.md b/docs/content/recipes/federation.md index aa0152c3c2b..46fc94b53ba 100644 --- a/docs/content/recipes/federation.md +++ b/docs/content/recipes/federation.md @@ -15,8 +15,8 @@ Uncomment federation configuration in your `gqlgen.yml` ```yml # Uncomment to enable federation federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph ``` ### Federation 2 @@ -25,8 +25,8 @@ If you are using Apollo's Federation 2 standard, your schema should automaticall ```yml federation: - filename: graph/generated/federation.go - package: generated + filename: graph/federation.go + package: graph version: 2 ``` diff --git a/init-templates/gqlgen.yml.gotmpl b/init-templates/gqlgen.yml.gotmpl index 1ca1dd2d504..5c485c2aff5 100644 --- a/init-templates/gqlgen.yml.gotmpl +++ b/init-templates/gqlgen.yml.gotmpl @@ -4,13 +4,13 @@ schema: # Where should the generated server code go? exec: - filename: graph/generated/generated.go - package: generated + filename: graph/generated.go + package: graph # Uncomment to enable federation # federation: -# filename: graph/generated/federation.go -# package: generated +# filename: graph/federation.go +# package: graph # Where should any generated models go? model: