gqlgen generate failed when the Resolver contains multiple-line comments
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
Executing go run github.com/99designs/gqlgen generate resulted in failure when the Resolver contained a method with multiple-line comments.
Below is the result of generation including multiple-line comments:
```go
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.
// Code generated by github.com/99designs/gqlgen version v0.17.46
import (
"context"
"fmt"
"io"
"strconv"
"time"
"sync"
"errors"
"bytes"
gqlparser "github.com/vektah/gqlparser/v2"
"github.com/vektah/gqlparser/v2/ast"
"github.com/99designs/gqlgen/graphql"
"github.com/99designs/gqlgen/graphql/introspection"
"github.com/moonorange/gqlgen_test/graph/model")
// CreateTodo is the resolver for the createTodo field.
test
func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) ( *model.Todo, error){
panic(fmt.Errorf("not implemented: CreateTodo - createTodo"))
}
// Todos is the resolver for the todos field.
func (r *queryResolver) Todos(ctx context.Context) ( []*model.Todo, error){
panic(fmt.Errorf("not implemented: Todos - todos"))
}
// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
type mutationResolver struct { *Resolver }
type queryResolver struct { *Resolver }
```
### What did you expect?
Expected the generation of the resolver from the schema to proceed smoothly even when methods with multiple-line comments were present.
### Minimal graphql.schema and models to reproduce
Exactly the same as the tutorial.
```graphql.schema
# GraphQL schema example
#
# https://gqlgen.com/getting-started/
type Todo {
id: ID!
text: String!
done: Boolean!
user: User!
}
type User {
id: ID!
name: String!
}
type Query {
todos: [Todo!]!
}
input NewTodo {
text: String!
userId: String!
}
type Mutation {
createTodo(input: NewTodo!): Todo!
}
```
Exactly the same as the tutorial except for multiple line comments.
schema.resolvers.go
```go
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.
// Code generated by github.com/99designs/gqlgen version v0.17.46
//go:generate go run github.com/99designs/gqlgen generate
import (
"context"
"fmt"
"github.com/moonorange/gqlgen_test/graph/model"
)
// CreateTodo is the resolver for the createTodo field.
// test
func (r *mutationResolver) CreateTodo(ctx context.Context, input model.NewTodo) (*model.Todo, error) {
panic(fmt.Errorf("not implemented: CreateTodo - createTodo"))
}
// Todos is the resolver for the todos field.
func (r *queryResolver) Todos(ctx context.Context) ([]*model.Todo, error) {
panic(fmt.Errorf("not implemented: Todos - todos"))
}
// Mutation returns MutationResolver implementation.
func (r *Resolver) Mutation() MutationResolver { return &mutationResolver{r} }
// Query returns QueryResolver implementation.
func (r *Resolver) Query() QueryResolver { return &queryResolver{r} }
type mutationResolver struct{ *Resolver }
type queryResolver struct{ *Resolver }
```
### versions
- `go run github.com/99designs/gqlgen version`? v0.17.46
- `go version`? go1.22.2 darwin/arm64
Contributor guide
Assessment
This issue has not been assessed yet.