99designs / 99designs/gqlgen

Omit return values for interface/union options that aren't specified with inline fragments

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

描述

### What happened?

When a user queries for specific types of an interface and only wants one type in the response, an empty map is returned for the unspecified fragments/types.

### What did you expect?

The option should be provided for those empty maps to be omitted.

### Minimal graphql.schema and models to reproduce

schema:
```
interface Animal {
id string
}

type Dog implements Animal {
furLength int
id string
}

type Cat implements Animal {
meowPitch int
id string
}

```
and a query for:
```
animals {
... on Dog {
furLength
id
}
}
```
would potentially return two objects in the array, one empty and one expected. The empty ones should be omitted

### versions
- `go run github.com/99designs/gqlgen version`? 0.17.22
- `go version`? 1.19.4

贡献指南

打开贡献指南

调研方向

该 issue 涉及 gqlgen 如何处理接口/联合类型的 inline fragment。查看接口和联合类型的代码生成,可能位于 codegen 包中。检查 fragment 中只指定部分类型时 response 是如何构建的。目标是省略未指定类型对应的空 map。首先了解 resolver 生成和 response marshaling 逻辑。检查现有的接口/联合类型处理测试,以了解当前行为,并为新功能添加测试。

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

评估

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

把新 issue 发到你的邮箱

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