Project files
This commit is contained in:
0
receipeServer/graphqlapi/__init__.py
Normal file
0
receipeServer/graphqlapi/__init__.py
Normal file
3
receipeServer/graphqlapi/admin.py
Normal file
3
receipeServer/graphqlapi/admin.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
6
receipeServer/graphqlapi/apps.py
Normal file
6
receipeServer/graphqlapi/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class GraphqlapiConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'graphqlapi'
|
||||
3
receipeServer/graphqlapi/models.py
Normal file
3
receipeServer/graphqlapi/models.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
39
receipeServer/graphqlapi/schema.py
Normal file
39
receipeServer/graphqlapi/schema.py
Normal file
@@ -0,0 +1,39 @@
|
||||
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)
|
||||
|
||||
3
receipeServer/graphqlapi/tests.py
Normal file
3
receipeServer/graphqlapi/tests.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
3
receipeServer/graphqlapi/views.py
Normal file
3
receipeServer/graphqlapi/views.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user