【发布时间】:2023-04-05 23:47:01
【问题描述】:
我的一个服务上有一个 graphene.ObjectType 模型,它扩展了另一个服务中的定义
@extend(fields="id")
class ExtendedProtectedObject(graphene.ObjectType):
id = external(graphene.ID(required=True))
additional_color = graphene.String()
class Meta:
interfaces = (relay.Node,)
def resolve_additional_color(self, info):
return "blue"
@staticmethod
def _ExtendedProtectedObject__resolve_reference(root, info):
# root is an instance of self class with id set to the query id value
return root
我们运行 Apollo Federation 以将我们所有的 graphql 模式组合在一个位置并路由查询/突变等。 我可以在我的服务中添加什么查询作为单元测试,这反映了我在附加颜色字段上请求时 Apollo 所做的事情? 例如这个查询:
query getExtendedProtectedObject($id: ID!) {
extendedProtectedObject(id: $id) {
additionalColor
}
}
联合将什么查询转发到我的服务? 我想在我的服务中的一个单元测试中使用该查询,因为它会在访问任何字段解析器之前调用 ExtendedProtectedObject 方法 _ExtendedProtectedObject__resolve_reference。
【问题讨论】:
标签: python-3.x graphql apollo-server graphene-python