使用GQLGEN的联合GraphQl上下文
如何在已从联合GraphQl Gateway传递的GQLGEN子图中获取GraphQl上下文?
How do you get the graphql context in a gqlgen subgraph that has been passed down from the federated graphql gateway?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在网关中添加
buildservice
函数,该函数将JSON串起网关中的上下文,然后将其注入将发送到子图中的标头,然后在该子图中,您需要分析该标头并自己将其放在上下文中,以便您的决心可以访问它。这样的事情:You would need to add a
buildService
function in your gateway that json stringifies the context in the gateway and then injects that into a header that will be sent to the subgraph and then in the subgraph you will need to parse that header and put that into the context yourself so your resolves can access it. Something like this: