99designs / 99designs/gqlgen

Codegen creates extra code on INPUT_OBJECT directive when using nested input fields?

未关闭
#3,009 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Go
星标
10.8k
派生
1.3k
平均合并
2 天 36 分钟
30 天内合并 PR
26

描述

### 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`

贡献指南

打开贡献指南

调研方向

问题出在带有 @oneOf 指令的 GraphQL 输入对象的代码生成中。查看生成的解组代码,可能位于类似 generated.go 的文件中。比较该指令应用于嵌套 Destination 字段与应用于顶层 DirectionInput 的方式。使用提供的 schema 运行代码生成以重现问题,然后检查 graphql/generated 包。可能需要在 codegen tests 目录中添加或更新测试用例。

由索引模型根据 Issue 内容生成。

评估

技术栈
go, graphql
领域
api, backend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。