简体   繁体   中英

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). Here is my schema down below

I tried including the "exclude_fields" property but that didn't work

class Product(SQLAlchemyObjectType):
 class Meta:
  model = ProductModel
  interfaces = (relay.Node, )

class ProductConnections(relay.Connection):
 class Meta:
  node = Product

class SalableProduct(SQLAlchemyObjectType):
 class Meta:
  model = SalableProductModel
  interfaces = (relay.Node, )

class SalableProductConnections(relay.Connection):
 class Meta:
  node = SalableProduct

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.

(product_status is a propery shared by the two classes by inheritance)

I was having the same issue. In my particular case the issue is a conflict internal workings of SQLAlchemy when a backref is used. 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. The related model has a many to many relationship with techniques and belts.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM