[英]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.