Я новичок в graphql , и мне трудно использовать схему из двух разных приложений в django -graphql?
app1 hero schema.py
import graphene
from graphene_django import DjangoObjectType
from .models import Hero
class HeroType(DjangoObjectType):
class Meta:
model = Hero
class Query(graphene.ObjectType):
heroes = graphene.List(HeroType)
def resolve_heroes(self, info, **kwargs):
return Hero.objects.all()
app2 product schema.py
class ProductType(DjangoObjectType):
class Meta:
model = Product
class Query(object):
allproducts = graphene.List(ProductType, search=graphene.String(),limit=graphene.Int(),skip=graphene.Int(), offset=graphene.Int())
def resolve_allproducts(self, info, search=None, limit=None, skip=None, offset=None, **kwargs):
# Querying a list of products
qs = Product.objects.all()
data = []
if search:
filter = (
Q(name__icontains=search)|
Q(price__icontains=search)
)
qs = qs.filter(filter)
if skip:
qs = qs[skip:]
if limit:
# qs = qs[:limit]
qs = qs[int(offset):(int(offset) + int(limit))]
return qs
Моя проблема:
В основном проекте schema.py, как вызвать схему из app1-hero и app2-product?