99designs / 99designs/gqlgen

How can I avoid gqlgen always generate extra reslover that i dont need

未关闭
#2,623 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
10.8k
派生
1.3k
平均合并
2 天 36 分钟
30 天内合并 PR
26

描述

### 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`?

贡献指南

打开贡献指南

调研方向

查看 gqlgen 配置文件(gqlgen.yaml)和 GraphQL schema 定义。了解自定义标量和模型映射的工作方式。这个 issue 涉及为标量类型和嵌套 struct 生成不需要的 resolver。检查 codebase 中的 resolver 生成逻辑,可能位于代码生成 package 中。查看现有的 resolver 生成测试,以了解预期行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
go, graphql
领域
api, backend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。