"Must be called from within _entities" on cyclic federated request
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
## The Config
`gqlgen.yml`:
```
federation:
filename: graph/federation.go
package: graph
version: 2
options:
computed_requires: true
call_argument_directives_with_null: true
```
## The Schemas
`serviceA.graphqls`:
```
type Query {
entityA(entityAId: String!): EntityA
}
type EntityA @key(fields: "entityAId") {
entityAId: String!
entityB: EntityB @provides(fields: "entityBId")
}
type EntityB @key(fields: "entityBId") @extends {
entityBId: String! @external
entityA: EntityA @requires(fields: "entityBId")
}
```
`serviceB.graphqls`:
```
type Query {
entityB(entityBId: String!): EntityB
}
type EntityB @key(fields: "entityBId") {
entityBId: String!
}
```
## The Test
Request through Apollo Router:
```
query Query {
entityA(entityAId: "EntityAId") {
entityAId
entityB {
entityBId
entityA {
entityAId
}
}
}
}
```
Response:
```
{
"data": {
"entityA": {
"entityAId": "EntityAId",
"entityB": {
"entityBId": "EntityBId",
"entityA": null
}
}
},
"errors": [
{
"message": "must be called from within _entities",
"path": [
"entityA",
"entityB",
"entityA"
],
"extensions": {
"service": "serviceA"
}
}
]
}
```
贡献指南
调研方向
问题出在 federation resolver 逻辑中,可能位于生成的 federation.go 文件中。检查 _entities 调用的结构,以及循环依赖检查失败的位置。首先跟踪 serviceA 中 EntityA.entityB.entityA 的 resolver 路径,并与 federation spec 中关于处理循环 requires/provides 的规定进行比较。查看测试输出,以了解确切的错误上下文。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go, graphql
- 领域
- api, backend
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100