微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Apollo Federation网关:如何将不同的“密钥”发送到不同的实现微服务?

如何解决Apollo Federation网关:如何将不同的“密钥”发送到不同的实现微服务?

我正在尝试使用网关和 3 个实现微服务的联合 apollo 服务。

MS1:

type Movie @key(fields: "id name") {
    id: String!
    name: String
}

MS2:

type Location @key(fields: "id") {
    id: String!
    longitude: Float!
    latitude: Float!
} 

type Movie @key(fields: "id") @extends {
    id: String! @external
    location: Location
}

MS3:

type Award @key(fields: "name"){
    name: String!
    count: Int
} 

type Movie @key(fields: "name") @extends {
    name: String! @external
    award: Award
}

MS1 提供了一个 name一个 idname 应发送到 MS3 进行解析过程,id 应由 MS2 用于解析过程。

方法适用于较旧版本的 apollo-gateway / apollo-server,但使用最新版本时,我收到以下错误消息。

{"stack":"Error: A valid schema Couldn't be composed. The following composition errors were found:\n\t[ms2] Movie -> extends from ms1 but specifies an invalid @key directive. Valid @key directives are specified by the originating type. Available @key directives for this type are:\n\t@key(fields: \"id name\")\n   ...}

提供这样的密钥的方法也不起作用:

type Movie @key(fields: "id") @key(fields: "name") {

要提供所描述的用例,架构必须是什么样的?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。