我正在使用 apollo federation 并遇到错误,当尝试制作类似于计算字段的东西时(https://www.apollographql.com/docs/federation/entities/#extending-an-entity-with-computed-fields-高级):
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
类型来获得订阅。