Codegen creates extra code on INPUT_OBJECT directive when using nested input fields?
- 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?
I have following gql schema:
with schema below when I run code gen it creates unmarshaling function with directive function call for `flightable_place` and `non_flightable_place` fields which passes parent input object(destination) to my `OneOf` implementation function, which it should do, but also it does the same for `destination` field and passes it's parent input object which is main `DirectionInput` input object to `OneOf` directive implementation, which it shouldn't because it doesn't make any sense and oneOf directive doesn't get called on `DirectionInput`
### What did you expect?
Am I doing something wrong and what should I expect from following schema?
### Minimal graphql.schema and models to reproduce
```
directive @oneOf on INPUT_OBJECT
input Destination @oneOf {
flightable_place: FlightablePlace
non_flightable_place: NonFlightablePlace
}
input FlightablePlace {
iata: String!
}
input NonFlightablePlace {
uuid: String!
}
input DirectionInput {
destination: Destination!
some_field: String
some_field2: Int
}
type Query {
direction(input: QueryInput!): Direction
}
type Direction {
origin: String
destination: String
}
```
### versions
- `github.com/99designs/gqlgen v0.17.45`
- `1.22.1`
Hướng dẫn đóng góp
Hướng nghiên cứu
Vấn đề nằm trong phần sinh mã cho các đối tượng đầu vào GraphQL có chỉ thị @oneOf. Hãy xem mã unmarshaling được sinh ra, có thể nằm trong một tệp như generated.go. So sánh cách chỉ thị được áp dụng cho trường Destination lồng nhau với cách áp dụng cho DirectionInput ở cấp cao nhất. Chạy quá trình sinh mã trên schema được cung cấp để tái hiện vấn đề, sau đó kiểm tra package graphql/generated. Có thể cần thêm hoặc cập nhật một test case trong thư mục kiểm thử codegen.
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ó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100