Вопрос о том, как использовать графеновые союзы с полиморфным django
У меня есть несколько полиморфных моделей
class Product(PolymorphicModel):
name = models.CharField(max_length=200)
class Item(Product):
pass
class Service(Product):
pass
И я пытаюсь реализовать django-graphene Но я не знаю, как правильно это сделать
class ItemType(DjangoObjectType):
class Meta:
model = Item
fields = "__all__"
class ServiceType(DjangoObjectType):
class Meta:
model = Service
fields = "__all__"
class ProductType(graphene.Union):
class Meta:
types = (ItemType, ServiceType)
Это мой запрос:
class Query(graphene.ObjectType):
products = graphene.List(ProductType)
items = graphene.List(ItemType)
services = graphene.List(SeriveType)
def resolve_products(self, info):
return Product.objects.all()
def resolve_items(self, info):
return Item.objects.all()
def resolve_services(self, info):
return Service.objects.all()
Я хочу получить все продукты (экземпляры Items и Services) сразу, но не понимаю, как это сделать!
{
products {
name
}
}
возвращает:
"Cannot query field 'name' on type 'ProductType'. Did you mean to use an inline fragment on 'ItemType' or 'ServiceType'?"
как получить все объекты сразу?