graphene-sqlalchemy: 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), in my Schema here is what i did
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
and here is my Query class :
class Query(graphene.ObjectType):
node = relay.Node.Field()
all_products = SQLAlchemyConnectionField(ProductConnections)
all_salable_products = SQLAlchemyConnectionField(SalableProductConnections)
When i run my server i got this error :
AssertionError: Found different types with the same name in the schema: product_status, product_status.
About this issue
- Original URL
- State: open
- Created 5 years ago
- Reactions: 3
- Comments: 19 (4 by maintainers)
I use this monkey-patch on my projects:
So, for the record, I solved this by making global SQLAlchemy types, so @richin13 , your code would become:
I’m running into this issue. I defined my model like this:
Which fails with:
Versions:
Yes, I mean one code location for both solutions. Not multiple locations. Only one location uses lru_cache.
That is… really creative! Thanks!