How can I avoid gqlgen always generate extra reslover that i dont need
- Dominant language
- Go
- Stars
- 10.8k
- Forks
- 1.3k
- Avg merge
- 2d 36m
- Merged PRs (30d)
- 26
Description
### What happened?
when i define a graphl gen with "scalar time" type , it will generate an extra reslover to me
```
scalar Time
type User {
id: ID!
firstname: String!
lastname: String!
email: String!
hashedPassword: String!
birthday: Time!
}
```
it generate an "birthday" reslover , that i don't want
```
// CreateUser is the resolver for the createUser field.
func (r *mutationResolver) CreateUser(ctx context.Context, input schema.CreateUserInput) (*model.User, error) {
panic(fmt.Errorf("not implemented: CreateUser - createUser"))
}
// Birthday is the resolver for the birthday field.
func (r *createUserInputResolver) Birthday(ctx context.Context, obj *schema.CreateUserInput, data *time.Time) error {
panic(fmt.Errorf("not implemented: Birthday - birthday"))
}
```
when i try to use gqlgen.yaml configure a self defined models
```
models:
ReqPdConfig:
model:
- shihansin/server/db/syncworker.ReqPdConfig
```
ReqPdConfig is a struct include multiple struct , but itself is a whole big struct , but it generate many resolver to me
```
func (r *reqPdConfigResolver) AwardConfig(ctx context.Context, obj *syncworker.ReqPdConfig, data []*graphql1.AwardInput) error {
panic(fmt.Errorf("not implemented: AwardConfig - awardConfig"))
}
// Qa is the resolver for the qa field.
func (r *reqPdConfigResolver) Qa(ctx context.Context, obj *syncworker.ReqPdConfig, data []*graphql1.QAInput) error {
panic(fmt.Errorf("not implemented: Qa - qa"))
}
// HighLight is the resolver for the highLight field.
func (r *reqPdConfigResolver) HighLight(ctx context.Context, obj *syncworker.ReqPdConfig, data []*graphql1.HighlightInput) error {
panic(fmt.Errorf("not implemented: HighLight - highLight"))
}
// AboutProduct is the resolver for the aboutProduct field.
func (r *reqPdConfigResolver) AboutProduct(ctx context.Context, obj *syncworker.ReqPdConfig, data []*graphql1.AboutProductInput) error {
panic(fmt.Errorf("not implemented: AboutProduct - aboutProduct"))
}
// Mutation returns graphql1.MutationResolver implementation.
func (r *Resolver) Mutation() graphql1.MutationResolver { return &mutationResolver{r} }
// ReqPdConfig returns graphql1.ReqPdConfigResolver implementation.
func (r *Resolver) ReqPdConfig() graphql1.ReqPdConfigResolver { return &reqPdConfigResolver{r} }
```
### What did you expect?
how can i avoid it , which is only generate one single reslover , or generate the reslover that i want
### Minimal graphql.schema and models to reproduce
### versions
- `go run github.com/99designs/gqlgen version`?
- lastest version
- `go version`?
Contributor guide
Research direction
Look at the gqlgen configuration file (gqlgen.yaml) and the GraphQL schema definitions. Understand how custom scalars and model mappings work. The issue is about unwanted resolver generation for scalar types and nested structs. Check the resolver generation logic in the codebase, likely in the code generation package. Review existing tests for resolver generation to see the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, graphql
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100