2023-11-09 18:47:11 +01:00

40 lines
857 B
Python

import graphene
from receipe.models import Purchase, Article
from graphene_django.types import DjangoObjectType
# api-movie-model
class ArticleType(DjangoObjectType):
class Meta:
model = Article
fields = ("RowId",
"name")
class PurchaseType(DjangoObjectType):
class Meta:
model = Purchase
fields = ("purchase_date",
"payment_type",
"total_price",
"articles",
"created",
"modified")
class Query(graphene.ObjectType):
purchase = graphene.List(PurchaseType)
article = graphene.List(ArticleType)
def resolve_purchase(root, info):
return Purchase.objects.all()
def resolve_article(root, info):
return Article.objects.all()
schema = graphene.Schema(query=Query)