From cb380814a754ab7e9c7dbb25a3258b98432120dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Kucharczyk?= Date: Wed, 29 Nov 2023 21:04:35 +0100 Subject: [PATCH] Move GraphQL to separata app --- api/__init__.py | 0 api/admin.py | 3 +++ api/apps.py | 6 ++++++ api/migrations/__init__.py | 0 api/models.py | 3 +++ {games => api}/schema.py | 12 ++++++------ api/tests.py | 3 +++ api/views.py | 3 +++ timetracker/settings.py | 3 ++- 9 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 api/__init__.py create mode 100644 api/admin.py create mode 100644 api/apps.py create mode 100644 api/migrations/__init__.py create mode 100644 api/models.py rename {games => api}/schema.py (86%) create mode 100644 api/tests.py create mode 100644 api/views.py diff --git a/api/__init__.py b/api/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/admin.py b/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/api/apps.py b/api/apps.py new file mode 100644 index 0000000..878e7d5 --- /dev/null +++ b/api/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ApiConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "api" diff --git a/api/migrations/__init__.py b/api/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/models.py b/api/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/api/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/games/schema.py b/api/schema.py similarity index 86% rename from games/schema.py rename to api/schema.py index a5d2908..98f3860 100644 --- a/games/schema.py +++ b/api/schema.py @@ -1,12 +1,12 @@ import graphene from graphene_django import DjangoObjectType -from .models import Device as DeviceModel -from .models import Edition as EditionModel -from .models import Game as GameModel -from .models import Platform as PlatformModel -from .models import Purchase as PurchaseModel -from .models import Session as SessionModel +from games.models import Device as DeviceModel +from games.models import Edition as EditionModel +from games.models import Game as GameModel +from games.models import Platform as PlatformModel +from games.models import Purchase as PurchaseModel +from games.models import Session as SessionModel class Game(DjangoObjectType): diff --git a/api/tests.py b/api/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/api/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/api/views.py b/api/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/api/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/timetracker/settings.py b/timetracker/settings.py index 6386976..47e5e21 100644 --- a/timetracker/settings.py +++ b/timetracker/settings.py @@ -33,6 +33,7 @@ ALLOWED_HOSTS = ["*"] INSTALLED_APPS = [ "games.apps.GamesConfig", + "api.apps.ApiConfig", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", @@ -41,7 +42,7 @@ INSTALLED_APPS = [ "graphene_django", ] -GRAPHENE = {"SCHEMA": "games.schema.schema"} +GRAPHENE = {"SCHEMA": "api.schema.schema"} if DEBUG: INSTALLED_APPS.append("django_extensions")