99designs / 99designs/gqlgen

proposal: Federation plugin: combination of `explicit_requires` with entity multi-resolver works as not expected

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

描述

### What happened?
Suppose you have an entity type, and your subgraph adds field to it - some function, that `@requires` other `@external` field in this entity. If you turn on `federation:options:explicit_requires: true` in your `gqlgen.yml`, it will generate `FindMany...` entity resolver. But will not generate `federation.requires.go` file with resolving `@requires` fields. However, it just fills all nested `@requires` fields in `federation.go` generated code, so, it will cause panic, if some nested fields in `@requires` are optional/mutually exclusive.

### What did you expect?
Generating `federation.requires.go` with `Populate...` method, that takes list of entities and reps map as an argument.

### Minimal graphql.schema and models to reproduce

In this example, to process `getHeroWithWeapon`, we need both `importantInfo` and fields in `@requires`:
```
type Hero @key(fileds: "id") @entityResolver(multi:true){
id: ID!
weapon: Weapon @external
getHeroWithWeapon(
importantInfo: SomeHeroInfo!
): DangerousHero @requires(fields: "weapon { id slug }")
}

type Weapon @shareable{
// we can identify weapon by ID OR Slug:
id: ID
slug: String
}
```
### versions
- `go run github.com/99designs/gqlgen version`?

`v0.17.45`
- `go version`?

`go version go1.21.8 darwin/arm64`

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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