[英]AssertionError: Found different types with the same name in the schema
我有两个类:模型中的Products和SalableProducts(SalableProducts继承自Products,因此它具有数据库的每个字段)。 这是我的下方架构
我尝试包括“ exclude_fields”属性,但这没有用
Product_schema.py:
class Product(SQLAlchemyObjectType):
class Meta:
model = ProductModel
interfaces = (relay.Node, )
class ProductConnections(relay.Connection):
class Meta:
node = Product
Salable_product_schema.py:
class SalableProduct(SQLAlchemyObjectType):
class Meta:
model = SalableProductModel
interfaces = (relay.Node, )
class SalableProductConnections(relay.Connection):
class Meta:
node = SalableProduct
Schema.py:
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_products = SQLAlchemyConnectionField(ProductConnections)
all_salable_products =
SQLAlchemyConnectionField(SalableProductConnections)
结果是此错误:
AssertionError:在架构中找到了具有相同名称的不同类型:product_status,product_status。
(product_status是两个类通过继承共享的属性)
我有同样的问题。 在我的特定情况下,问题是使用backref时SQLAlchemy的内部工作方式冲突。 我会检查模型,看看是否是这种情况。
以下文章具有一些相关信息。 在我的特殊情况下,我尝试了建议的方法并重命名了其中一个连接:
techniques = SQLAlchemyConnectionField(TechniqueConnection)
belts = SQLAlchemyConnectionField(BeltConnection)
belt_techniques = SQLAlchemyConnectionField(BeltTechniqueConnections)
我在BeltTechniqueConnection后面附加了一个“ s”。 相关的模型与技术和皮带有很多关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.