Skip to content

Commit

Permalink
suppress golint messages
Browse files Browse the repository at this point in the history
  • Loading branch information
vvakame committed Feb 20, 2020
1 parent a53ce37 commit 81bcbe7
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 23 deletions.
6 changes: 6 additions & 0 deletions codegen/templates/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type Options struct {
GeneratedHeader bool
// PackageDoc is documentation written above the package line
PackageDoc string
// FileNotice is notice written below the package line
FileNotice string
// Data will be passed to the template execution.
Data interface{}
Funcs template.FuncMap
Expand Down Expand Up @@ -144,6 +146,10 @@ func Render(cfg Options) error {
result.WriteString("package ")
result.WriteString(cfg.PackageName)
result.WriteString("\n\n")
if cfg.FileNotice != "" {
result.WriteString(cfg.FileNotice)
result.WriteString("\n\n")
}
result.WriteString("import (\n")
result.WriteString(CurrentImports.String())
result.WriteString(")\n")
Expand Down
42 changes: 32 additions & 10 deletions codegen/testserver/resolver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.
package testserver

// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.

import (
"context"

Expand Down Expand Up @@ -306,17 +307,38 @@ func (r *userResolver) Friends(ctx context.Context, obj *User) ([]*User, error)
panic("not implemented")
}

// BackedByInterface returns BackedByInterfaceResolver implementation.
func (r *Resolver) BackedByInterface() BackedByInterfaceResolver { return &backedByInterfaceResolver{r} }
func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} }
func (r *Resolver) ForcedResolver() ForcedResolverResolver { return &forcedResolverResolver{r} }
func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} }

// Errors returns ErrorsResolver implementation.
func (r *Resolver) Errors() ErrorsResolver { return &errorsResolver{r} }

// ForcedResolver returns ForcedResolverResolver implementation.
func (r *Resolver) ForcedResolver() ForcedResolverResolver { return &forcedResolverResolver{r} }

// ModelMethods returns ModelMethodsResolver implementation.
func (r *Resolver) ModelMethods() ModelMethodsResolver { return &modelMethodsResolver{r} }

// OverlappingFields returns OverlappingFieldsResolver implementation.
func (r *Resolver) OverlappingFields() OverlappingFieldsResolver { return &overlappingFieldsResolver{r} }
func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} }
func (r *Resolver) Primitive() PrimitiveResolver { return &primitiveResolver{r} }
func (r *Resolver) PrimitiveString() PrimitiveStringResolver { return &primitiveStringResolver{r} }
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} }
func (r *Resolver) User() UserResolver { return &userResolver{r} }

// Panics returns PanicsResolver implementation.
func (r *Resolver) Panics() PanicsResolver { return &panicsResolver{r} }

// Primitive returns PrimitiveResolver implementation.
func (r *Resolver) Primitive() PrimitiveResolver { return &primitiveResolver{r} }

// PrimitiveString returns PrimitiveStringResolver implementation.
func (r *Resolver) PrimitiveString() PrimitiveStringResolver { return &primitiveStringResolver{r} }

// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }

// Subscription returns SubscriptionResolver implementation.
func (r *Resolver) Subscription() SubscriptionResolver { return &subscriptionResolver{r} }

// User returns UserResolver implementation.
func (r *Resolver) User() UserResolver { return &userResolver{r} }

type backedByInterfaceResolver struct{ *Resolver }
type errorsResolver struct{ *Resolver }
Expand Down
8 changes: 6 additions & 2 deletions example/config/schema.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

// 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.
package config

import (
"context"
Expand All @@ -24,8 +25,11 @@ func (r *queryResolver) Todos(ctx context.Context) ([]*Todo, error) {
return r.todos, nil
}

// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }

// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }

type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
4 changes: 3 additions & 1 deletion example/config/todo.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

// 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.
package config

import (
"context"
Expand All @@ -17,6 +18,7 @@ func (r *todoResolver) ID(ctx context.Context, obj *Todo) (string, error) {
return obj.ID, nil
}

// Todo returns TodoResolver implementation.
func (r *Resolver) Todo() TodoResolver { return &todoResolver{r} }

type todoResolver struct{ *Resolver }
4 changes: 3 additions & 1 deletion example/federation/accounts/graph/entity.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graph

// 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.
package graph

import (
"context"
Expand All @@ -21,6 +22,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} }

type entityResolver struct{ *Resolver }
4 changes: 3 additions & 1 deletion example/federation/accounts/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graph

// 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.
package graph

import (
"context"
Expand All @@ -16,6 +17,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} }

type queryResolver struct{ *Resolver }
4 changes: 3 additions & 1 deletion example/federation/products/graph/entity.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graph

// 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.
package graph

import (
"context"
Expand All @@ -18,6 +19,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} }

type entityResolver struct{ *Resolver }
4 changes: 3 additions & 1 deletion example/federation/products/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graph

// 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.
package graph

import (
"context"
Expand All @@ -13,6 +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} }

type queryResolver struct{ *Resolver }
4 changes: 3 additions & 1 deletion example/federation/reviews/graph/entity.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graph

// 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.
package graph

import (
"context"
Expand All @@ -21,6 +22,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} }

type entityResolver struct{ *Resolver }
8 changes: 6 additions & 2 deletions example/federation/reviews/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graph

// 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.
package graph

import (
"context"
Expand Down Expand Up @@ -33,8 +34,11 @@ func (r *userResolver) Reviews(ctx context.Context, obj *model.User) ([]*model.R
return res, nil
}

// Product returns generated.ProductResolver implementation.
func (r *Resolver) Product() generated.ProductResolver { return &productResolver{r} }
func (r *Resolver) User() generated.UserResolver { return &userResolver{r} }

// User returns generated.UserResolver implementation.
func (r *Resolver) User() generated.UserResolver { return &userResolver{r} }

type productResolver struct{ *Resolver }
type userResolver struct{ *Resolver }
6 changes: 3 additions & 3 deletions plugin/resolvergen/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (m *Plugin) generateSingleFile(data *codegen.Data) error {

return templates.Render(templates.Options{
PackageName: data.Config.Resolver.Package,
PackageDoc: `// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.`,
FileNotice: `// THIS CODE IS A STARTING POINT ONLY. IT WILL NOT BE UPDATED WITH SCHEMA CHANGES.`,
Filename: data.Config.Resolver.Filename,
Data: resolverBuild,
Packages: data.Config.Packages,
Expand Down Expand Up @@ -132,7 +132,7 @@ func (m *Plugin) generatePerSchema(data *codegen.Data) error {

err := templates.Render(templates.Options{
PackageName: data.Config.Resolver.Package,
PackageDoc: `
FileNotice: `
// 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.`,
Filename: filename,
Expand All @@ -147,7 +147,7 @@ func (m *Plugin) generatePerSchema(data *codegen.Data) error {
if _, err := os.Stat(data.Config.Resolver.Filename); os.IsNotExist(errors.Cause(err)) {
err := templates.Render(templates.Options{
PackageName: data.Config.Resolver.Package,
PackageDoc: `
FileNotice: `
// This file will not be regenerated automatically.
//
// It serves as dependency injection for your app, add any dependencies you require here.`,
Expand Down
1 change: 1 addition & 0 deletions plugin/resolvergen/resolver.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
{{ end }}

{{ range $object := .Objects -}}
// {{$object.Name}} returns {{ $object.ResolverInterface | ref }} implementation.
func (r *{{$.ResolverType}}) {{$object.Name}}() {{ $object.ResolverInterface | ref }} { return &{{lcFirst $object.Name}}{{ucFirst $.ResolverType}}{r} }
{{ end }}

Expand Down

0 comments on commit 81bcbe7

Please sign in to comment.