struct field is created even though `forceResolver: true`
- 主要言語
- Go
- スター
- 10.8k
- フォーク
- 1.3k
- 平均マージ
- 2日 36分
- マージ済み PR(30日)
- 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 は、forceResolver: true が使用されたときに gqlgen コードジェネレーターが誤って構造体フィールドを追加する問題に関するものです。gqlgen プロジェクトのコード生成ロジックを調べてください。おそらく plugin またはモデル生成コードにあります。まず、@goField ディレクティブがどのように処理され、構造体フィールドがどこで生成されるかを確認してください。現在の動作を理解するために、models_gen.go の出力を確認してください。修正では、forceResolver が true の場合に構造体フィールドの作成をスキップするようジェネレーターを変更します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- go
- 領域
- backend-api-design
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100