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 (将#修改为@)