gqlgen generates non compilable code when schema has Entity interfaces
- Ngôn ngữ chính
- Go
- Star
- 10.8k
- Fork
- 1.3k
- Merge trung bình
- 2 ngày 36 phút
- Pull request đã merge (30 ngày)
- 26
Mô tả
### 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`
Hướng dẫn đóng góp
Hướng nghiên cứu
Vấn đề nằm ở phần tạo mã cho các interface GraphQL với chỉ thị @key của Apollo Federation. Hãy xem logic tạo mã của gqlgen, có thể nằm trong các package tạo plugin hoặc model, nơi các interface được xử lý. Interface User được tạo cũng phải triển khai fedruntime.Entity. Kiểm tra các test hiện có cho federation hoặc việc tạo entity để hiểu đầu ra mong đợi và thêm một test case cho schema này.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- go, graphql
- Lĩnh vực
- api, backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100