AssertionError: Found different types with the same name in the schema

3.1k Views Asked by At

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

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)

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)

1

There are 1 best solutions below

2
On BEST ANSWER

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.