[英]AssertionError: Found different types with the same name in the schema
I have two classes: Products and SalableProducts in my models (SalableProducts inherits from Products so it has every field of it's database). 我有两个类:模型中的Products和SalableProducts(SalableProducts继承自Products,因此它具有数据库的每个字段)。 Here is my schema down below 这是我的下方架构
I tried including the "exclude_fields" property but that didn't work 我尝试包括“ exclude_fields”属性,但这没有用
Product_schema.py: 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: Salable_product_schema.py:
class SalableProduct(SQLAlchemyObjectType):
class Meta:
model = SalableProductModel
interfaces = (relay.Node, )
class SalableProductConnections(relay.Connection):
class Meta:
node = SalableProduct
Schema.py: Schema.py:
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_products = SQLAlchemyConnectionField(ProductConnections)
all_salable_products =
SQLAlchemyConnectionField(SalableProductConnections)
The result is this error : 结果是此错误:
AssertionError: Found different types with the same name in the schema: product_status, product_status. AssertionError:在架构中找到了具有相同名称的不同类型:product_status,product_status。
(product_status is a propery shared by the two classes by inheritance) (product_status是两个类通过继承共享的属性)
I was having the same issue. 我有同样的问题。 In my particular case the issue is a conflict internal workings of SQLAlchemy when a backref is used. 在我的特定情况下,问题是使用backref时SQLAlchemy的内部工作方式冲突。 I would check the model to see if that is the case. 我会检查模型,看看是否是这种情况。
The following article has some relevant information. 以下文章具有一些相关信息。 In my particular case I tried what was suggested and renamed one of the connections: 在我的特殊情况下,我尝试了建议的方法并重命名了其中一个连接:
techniques = SQLAlchemyConnectionField(TechniqueConnection)
belts = SQLAlchemyConnectionField(BeltConnection)
belt_techniques = SQLAlchemyConnectionField(BeltTechniqueConnections)
I appended an 's' to the BeltTechniqueConnection. 我在BeltTechniqueConnection后面附加了一个“ s”。 The related model has a many to many relationship with techniques and belts. 相关的模型与技术和皮带有很多关系。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.