AssertionError: Found different types with the same name in the schema
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: Found different types with the same name in the schema: product_status, product_status.
(product_status是一个属性由两个类通过继承共享)
我遇到了同样的问题。在我的特殊情况下,问题是使用 backref 时 SQLAlchemy 的内部工作冲突。我会检查模型,看看是否是这种情况。
下面article有一些相关的信息。在我的特殊情况下,我尝试了建议的内容并重命名了其中一个连接:
techniques = SQLAlchemyConnectionField(TechniqueConnection)
belts = SQLAlchemyConnectionField(BeltConnection)
belt_techniques = SQLAlchemyConnectionField(BeltTechniqueConnections)
我向 BeltTechniqueConnection 添加了一个 's'。相关模型与技术和腰带具有多对多关系。
我的模型中有两个 类: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: Found different types with the same name in the schema: product_status, product_status.
(product_status是一个属性由两个类通过继承共享)
我遇到了同样的问题。在我的特殊情况下,问题是使用 backref 时 SQLAlchemy 的内部工作冲突。我会检查模型,看看是否是这种情况。
下面article有一些相关的信息。在我的特殊情况下,我尝试了建议的内容并重命名了其中一个连接:
techniques = SQLAlchemyConnectionField(TechniqueConnection)
belts = SQLAlchemyConnectionField(BeltConnection)
belt_techniques = SQLAlchemyConnectionField(BeltTechniqueConnections)
我向 BeltTechniqueConnection 添加了一个 's'。相关模型与技术和腰带具有多对多关系。