struct field is created even though `forceResolver: true`
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
### What happened?
I added `@goField(forceResolver: true)` to a field. As expected, a new resolver was added, but a field was also added to the struct in `models_gen.go`.
### What did you expect?
I expected for only the resolver to be created. Since that field is not being resolved as part of the struct i expected no field to be added to the struct.
### Minimal graphql.schema and models to reproduce
```
type User {
friends: [User!]! @goField(forceResolver: true)
}
```
### versions
- `gqlgen version`?
```
github.com/99designs/gqlgen v0.13.0 h1:haLTcUp3Vwp80xMVEg5KRNwzfUrgFdRmtBY8fuB8scA=
github.com/99designs/gqlgen v0.13.0/go.mod h1:NV130r6f4tpRWuAI+zsrSdooO/eWUv+Gyyoi3rEfXIk=
```
- `go version`?
```
go version go1.15.6 linux/amd64
```
- dep or go modules?
go mod
贡献指南
调研方向
该 issue 涉及 gqlgen 代码生成器在使用 forceResolver: true 时错误地添加结构体字段。查看 gqlgen 项目中的代码生成逻辑,可能位于插件或模型生成代码中。首先检查 @goField 指令的处理方式以及结构体字段生成的位置。检查 models_gen.go 的输出,以了解当前行为。修复将涉及修改生成器,以便在 forceResolver 为 true 时跳过创建结构体字段。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go
- 领域
- backend-api-design
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100