[英]Graphene AssertionError: Can't find type in schema
I create such schema using graphene v2.1.8 and looking into this example :我使用石墨烯 v2.1.8创建这样的模式并查看这个例子:
class Employee(graphene.Interface):
employee_id = graphene.ID()
employee_type = graphene.Field(lambda: EmployeeType)
@classmethod
def resolve_type(cls, instance, info):
if instance.get("employee_type") == EmployeeType.PART_TIME.name:
return PartTimeEmployee
return FullTimeEmployee
class PartTimeEmployee(graphene.ObjectType):
class Meta:
interfaces = (Employee, )
class FullTimeEmployee(graphene.ObjectType):
class Meta:
interfaces = (Employee, )
When I run query against it I got following error:当我针对它运行查询时,出现以下错误:
AssertionError: Can't find type PartTimeEmployee in schema
断言错误:在架构中找不到 PartTimeEmployee 类型
What do I do wrong here?我在这里做错了什么?
如果类型PartTimeEmployee
, FullTimeEmployee
不查询类中明确提到的-你必须在注册类型Schema
手动。
schema = Schema(query=Query, types=[PartTimeEmployee, FullTimeEmployee])
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.