Skip to content

Commit

Permalink
add example to lint
Browse files Browse the repository at this point in the history
  • Loading branch information
andrey1s committed Aug 7, 2019
1 parent cce06f1 commit 91966ef
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 23 deletions.
4 changes: 0 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ run:
tests: true
skip-dirs:
- bin
- vendor
- var
- tmp
- example/*

linters-settings:
errcheck:
Expand Down
1 change: 1 addition & 0 deletions example/dataloader/dataloaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type loaders struct {
itemsByOrder *ItemSliceLoader
}

// nolint: gosec
func LoaderMiddleware(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ldrs := loaders{}
Expand Down
2 changes: 2 additions & 0 deletions example/dataloader/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func (r *queryResolver) Customers(ctx context.Context) ([]*Customer, error) {
}

// this method is here to test code generation of nested arrays
// nolint: gosec
func (r *queryResolver) Torture1d(ctx context.Context, customerIds []int) ([]*Customer, error) {
result := make([]*Customer, len(customerIds))
for i, id := range customerIds {
Expand All @@ -74,6 +75,7 @@ func (r *queryResolver) Torture1d(ctx context.Context, customerIds []int) ([]*Cu
}

// this method is here to test code generation of nested arrays
// nolint: gosec
func (r *queryResolver) Torture2d(ctx context.Context, customerIds [][]int) ([][]*Customer, error) {
result := make([][]*Customer, len(customerIds))
for i := range customerIds {
Expand Down
8 changes: 4 additions & 4 deletions example/selection/selection.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
package selection

import (
context "context"
"context"
"fmt"
"time"

Expand Down Expand Up @@ -59,10 +59,10 @@ func (r *queryResolver) Events(ctx context.Context) ([]Event, error) {
}

func formatCollected(cf []graphql.CollectedField) []string {
var res []string
res := make([]string, len(cf))

for _, f := range cf {
res = append(res, fmt.Sprintf("%s as %s", f.Name, f.Alias))
for i, f := range cf {
res[i] = f.Name + " as " + f.Alias
}
return res
}
8 changes: 4 additions & 4 deletions example/starwars/resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ func (r *Resolver) Starship() generated.StarshipResolver {
}

func (r *Resolver) resolveCharacters(ctx context.Context, ids []string) ([]models.Character, error) {
var result []models.Character
for _, id := range ids {
result := make([]models.Character, len(ids))
for i, id := range ids {
char, err := r.Query().Character(ctx, id)
if err != nil {
return nil, err
}
result = append(result, char)
result[i] = char
}
return result, nil
}
Expand All @@ -71,7 +71,7 @@ func (r *droidResolver) FriendsConnection(ctx context.Context, obj *models.Droid

type friendsConnectionResolver struct{ *Resolver }

func (r *Resolver) resolveFriendConnection(ctx context.Context, ids []string, first *int, after *string) (*models.FriendsConnection, error) {
func (r *Resolver) resolveFriendConnection(_ context.Context, ids []string, first *int, after *string) (*models.FriendsConnection, error) {
from := 0
if after != nil {
b, err := base64.StdEncoding.DecodeString(*after)
Expand Down
22 changes: 11 additions & 11 deletions example/type-system-extension/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"net/http"
"os"

"github.com/99designs/gqlgen/example/type-system-extension"
extension "github.com/99designs/gqlgen/example/type-system-extension"
"github.com/99designs/gqlgen/handler"
)

Expand All @@ -19,16 +19,16 @@ func main() {

http.Handle("/", handler.Playground("GraphQL playground", "/query"))
http.Handle("/query", handler.GraphQL(
type_system_extension.NewExecutableSchema(
type_system_extension.Config{
Resolvers: type_system_extension.NewRootResolver(),
Directives: type_system_extension.DirectiveRoot{
EnumLogging: type_system_extension.EnumLogging,
FieldLogging: type_system_extension.FieldLogging,
InputLogging: type_system_extension.InputLogging,
ObjectLogging: type_system_extension.ObjectLogging,
ScalarLogging: type_system_extension.ScalarLogging,
UnionLogging: type_system_extension.UnionLogging,
extension.NewExecutableSchema(
extension.Config{
Resolvers: extension.NewRootResolver(),
Directives: extension.DirectiveRoot{
EnumLogging: extension.EnumLogging,
FieldLogging: extension.FieldLogging,
InputLogging: extension.InputLogging,
ObjectLogging: extension.ObjectLogging,
ScalarLogging: extension.ScalarLogging,
UnionLogging: extension.UnionLogging,
},
},
),
Expand Down

0 comments on commit 91966ef

Please sign in to comment.