Apollo federation throws error: marked @external but is not defined on the base service of
Apollo federation throws error: marked @external but is not defined on the base service of
我正在使用 apollo federation 并在尝试制作类似于计算字段的内容时遇到错误 (https://www.apollographql.com/docs/federation/entities/#extending-an-entity-with-computed-fields-advanced):
Error: A valid schema couldn't be composed. The following composition errors were found:client-api-gateway_1
[Payments MS] User.parentId -> marked @external but parentId is not defined on the base service of User (Users MS)
我有两个服务:Users
和 Payments
。在 users
服务中,我存储有关用户的信息,并在 payments
中存储有关与用户相关的付款信息。
Users
服务图表:
type User @key(fields: "id") {
id: Int!
name: String!
surname: String!
type: USER_TYPE!
parentId: Int
}
Payments
服务图表:
type UserSubscriptionInfo {
nextChargeAmount: Int
......etc
}
extend type User @key(fields: "id") {
id: Int! @external
parentId: Int @external
subscription: UserSubscriptionInfo @requires(fields: "parentId")
}
基于 parentId
来自用户类型我想通过扩展 User
类型获得订阅。
确保将两个 graphql 模式放在同一个网关中。在我的应用程序中有 2 个不同的网关,我将它们放在 2 个不同的网关中。上面的代码运行完美。
我正在使用 apollo federation 并在尝试制作类似于计算字段的内容时遇到错误 (https://www.apollographql.com/docs/federation/entities/#extending-an-entity-with-computed-fields-advanced):
Error: A valid schema couldn't be composed. The following composition errors were found:client-api-gateway_1
[Payments MS] User.parentId -> marked @external but parentId is not defined on the base service of User (Users MS)
我有两个服务:Users
和 Payments
。在 users
服务中,我存储有关用户的信息,并在 payments
中存储有关与用户相关的付款信息。
Users
服务图表:
type User @key(fields: "id") {
id: Int!
name: String!
surname: String!
type: USER_TYPE!
parentId: Int
}
Payments
服务图表:
type UserSubscriptionInfo {
nextChargeAmount: Int
......etc
}
extend type User @key(fields: "id") {
id: Int! @external
parentId: Int @external
subscription: UserSubscriptionInfo @requires(fields: "parentId")
}
基于 parentId
来自用户类型我想通过扩展 User
类型获得订阅。
确保将两个 graphql 模式放在同一个网关中。在我的应用程序中有 2 个不同的网关,我将它们放在 2 个不同的网关中。上面的代码运行完美。