gqlgen generates non compilable code when schema has Entity interfaces
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
### What happened?
gqlgen generates non compilable code when schema has [Entity interfaces](https://www.apollographql.com/docs/federation/federated-types/interfaces/).
I've noticed this after trying to upgrade gqlgen from `v0.17.31` -> `v0.17.34`
### What did you expect?
It should generate compilable code
### Minimal graphql.schema and models to reproduce
```graphql
interface User @key(fields: "id") {
id: ID!
name: String!
email: String!
}
type Customer implements User @key(fields: "id") {
id: ID!
name: String!
email: String!
}
extend type Query {
me: User!
}
```
gqlgen is generating this model for the interface, but it doesn't implement the `fedruntime.Entity` interface.
```go
type User interface {
IsUser()
GetID() string
GetName() string
GetEmail() string
}
```
### versions
- `go run github.com/99designs/gqlgen version`? `v0.17.34`
- `go version go1.20.5 darwin/arm64`
贡献指南
调研方向
问题出在使用 Apollo Federation 的 @key 指令生成 GraphQL 接口的代码生成逻辑中。查看 gqlgen 的代码生成逻辑,可能位于处理接口的插件生成或模型生成包中。生成的 User 接口还必须实现 fedruntime.Entity。检查现有的 federation 或实体生成测试,以了解预期输出,并为此 schema 添加一个测试用例。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go, graphql
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100