You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are there plans to add support for union types in connections? I have a setup like the following:
class Cat(SQLAlchemyObjectType):
class Meta:
model = CatModel
interfaces = (relay.Node,)
class Dog(SQLAlchemyObjectType):
class Meta:
model = DogModel
interfaces = (relay.Node,)
class Animal(graphene.Union):
class Meta:
types = (Cat, Dog)
class Query(graphene.ObjectType):
animals = SQLAlchemyConnectionField(Animal)
and when I try to query for animals, I get the error: 'UnionOptions' object has no attribute 'model'.
I traced this back to the self.model call in wrap_resolve():
When the type is a union, get_nullable_type(self.type)._meta.node._meta returns the union class (in this case Animal). In order to get a model from that, we have to drill down into its types (e.g. get_nullable_type(self.type)._meta.node._meta.types[0]._meta.model) but because it's a union, it will contain multiple models.
Any ideas how to get around this?
The text was updated successfully, but these errors were encountered:
Are there plans to add support for union types in connections? I have a setup like the following:
and when I try to query for animals, I get the error:
'UnionOptions' object has no attribute 'model'
.I traced this back to the
self.model
call inwrap_resolve()
:When the type is a union,
get_nullable_type(self.type)._meta.node._meta
returns the union class (in this caseAnimal
). In order to get a model from that, we have to drill down into its types (e.g.get_nullable_type(self.type)._meta.node._meta.types[0]._meta.model
) but because it's a union, it will contain multiple models.Any ideas how to get around this?
The text was updated successfully, but these errors were encountered: