Avalidschemacouldn'tbecomposed.Thefollowingcompositionerrorswerefoundin@apollo/gateway
创始人
2024-11-12 18:00:21
0

这个错误通常是由于微服务中存在与其它服务中定义的类型重复的情况造成的。可以通过对类型进行命名空间处理或限定范围的方式来解决。具体操作可以在每个服务的 typedefs 中添加namespace,如下所示:

#User service
type User {
  id: ID!
  name: String!
}

#Order service
type Order {
  id: ID!
  user: User! @provides(fields: "id")
}

# Product service
type Product {
  id: ID!
  name: String!
  user: User! @provides(fields: "id")
}

然后在网关中使用 Apollo Gateway 提供的指令 @key 和 @keyFields 来关键字定义,以避免不同服务中相同的定义,如下所示:

# Gateway service
extend type User @key(fields: "id @namespace(name: \"user\")") {
  id: ID! @external
}

extend type Order @key(fields: "id") {
  id: ID! @external
  user: User @provides(fields: "id")
}

extend type Product @key(fields: "id") {
  id: ID! @external
  user: User @provides(fields: "id")
}

相关内容

热门资讯

解密透视!wpk控制牌是真的吗... 解密透视!wpk控制牌是真的吗,微乐自建房免费脚本哪个最好用,指南教程(真的有挂)-哔哩哔哩;进入游...
科普透视!大菠萝免费辅助,微乐... 科普透视!大菠萝免费辅助,微乐家乡麻辣自建房,方案教程(有挂方法)-哔哩哔哩1、许多玩家不知道大菠萝...
关于透视!aapoker透视脚... 关于透视!aapoker透视脚本入口,微乐四川小程序修改器,办法教程(有挂实锤)-哔哩哔哩aapok...
详情透视!aapoker怎么设... 您好,aapoker怎么设置提高好牌几率这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852...
有挂透视!购买wepoker模... 有挂透视!购买wepoker模拟器,微乐小程序免费黑科技在线下载,课程教程(有人有挂)-哔哩哔哩购买...
关于透视!德州透视hhpoke... 关于透视!德州透视hhpoker,微乐陕西小程序辅助,妙招教程(有挂秘笈)-哔哩哔哩1、玩家可以在德...
教你透视!wepoker作弊方... 教你透视!wepoker作弊方法,微信小程序微乐游戏修改器,法子教程(有挂规律)-哔哩哔哩1、用户打...
普及透视!aapoker透视插... 普及透视!aapoker透视插件,微信微乐自建房辅助工具,模块教程(有挂技巧)-哔哩哔哩小薇(辅助器...
详细透视!hh poker辅助... 详细透视!hh poker辅助有用吗,微乐小程序卡五星脚本,法门教程(有挂细节)-哔哩哔哩hh po...
推荐透视!智星德州插件2024... 推荐透视!智星德州插件2024最新版,微乐小程序自建房辅助下载,窍门教程(果真有挂)-哔哩哔哩1、不...