How can I achieve a shared context across a federated graph?
- 主要语言
- Go
- 星标
- 10.8k
- 派生
- 1.3k
- 平均合并
- 2 天 36 分钟
- 30 天内合并 PR
- 26
描述
I'm looking for some way to pass context about what 1 microservice resolved to the following microservices involved in serving the request.
```
Thing { # resolved by microservice 1
id
name
items {
id
name
stuff { # resolved by microservice 2
id
foo {
bar { # resolved by microservice 3
...barFields
}
}
}
}
}
```
In order for microservice 2 to resolve the fields of `stuff`, `items'` `stuff` field resolver must return something like
`{ id: item.stuffId}`.
In order for microservice 3 to resolve the fields of `bar`, `foo's` `bar` field resolver must return something like
`{ id: stuff.barId}`.
that all works just fine, but what if i wanted `barFields` in microservice 3 to have context about the `item` back in microservice 1?
From what I've observed so far, returning other fields besides `id` or `__typename` will be dropped when the request continues to the next microservice
贡献指南
调研方向
查看 federated gateway 以及它如何在服务之间传递上下文。issue 提到,除 id 和 __typename 之外的额外字段会被丢弃。首先检查 gqlgen 中 federation plugin 的代码,尤其是 federation package 以及它如何处理实体表示。查看 federation specification 中关于上下文传递的内容。第一步应当是编写一个能够复现字段丢弃的 test。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go, graphql
- 领域
- api, backend
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100