Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
imshezan committed May 31, 2023
1 parent 478941d commit a7b8c23
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 15 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
# template
# django boilerplate
# Bootstrap5 template
# Graphql query & mutation

# admin user password: admin, admin


Binary file modified backend/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file modified backend/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file modified backend/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file modified backend/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
6 changes: 3 additions & 3 deletions backend/schema.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import graphene
#import graphql_jwt

import api.apiSchema
import blog.apiSchema


class Query(
api.apiSchema.Query, # Add your Query objects here
blog.apiSchema.Query, # Add your Query objects here
graphene.ObjectType
):
pass

class Mutation(
api.apiSchema.Mutation, # Add your Mutation objects here
blog.apiSchema.Mutation, # Add your Mutation objects here
graphene.ObjectType
):
pass
Expand Down
4 changes: 3 additions & 1 deletion backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent

from django.utils.encoding import force_str
django.utils.encoding.force_text = force_str

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
Expand All @@ -31,7 +33,7 @@
'corsheaders',
"graphene_django",
'django_filters',
'api',
'blog',
]

MIDDLEWARE = [
Expand Down
2 changes: 1 addition & 1 deletion backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('api.urls')),
path('', include('blog.urls')),
path('graphql/', csrf_exempt(GraphQLView.as_view(graphiql=True)))

]
Expand Down
File renamed without changes.
File renamed without changes.
30 changes: 23 additions & 7 deletions api/apiSchema.py → blog/apiSchema.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from api.models import *
from blog.models import *

import graphene
from graphene_django import DjangoObjectType
Expand All @@ -18,10 +18,13 @@ class Meta:

class Query(graphene.ObjectType):
all_books = graphene.List(BookType)

def resolve_all_books(self, info):
return Book.objects.all()

book = graphene.Field(BookType, id=graphene.Int())
def resolve_book(self, info, id):
return Book.objects.get(pk=id)

class CreateBook(graphene.Mutation):
book = graphene.Field(BookType)

Expand All @@ -40,22 +43,35 @@ class Mutation(graphene.ObjectType):

schema = graphene.Schema(query=Query, mutation=Mutation)

#query operation example:
# Query operation example:

# Query operation for all books:
# query {
# book {
# allBooks {
# id
# title
# author
# description
# }
# }

# Query operation for a single book:
# query {
# book(id: 1) {
# id
# title
# author
# description
# }
# }


#Mutation operation example:
# mutation {
# createBook(
# title: "Book Title"
# author: "Author Name"
# description: "Book Description"
# title: "Book Title 4"
# author: "Author Name 4"
# description: "Book Description 4"
# ) {
# book {
# id
Expand Down
2 changes: 1 addition & 1 deletion api/apps.py → blog/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

class ApiConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'api'
name = 'blog'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.1 on 2023-05-24 11:40
# Generated by Django 4.2.1 on 2023-05-31 06:51

from django.db import migrations, models

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file modified db.sqlite3_test
Binary file not shown.
Binary file modified requirements.txt
Binary file not shown.

0 comments on commit a7b8c23

Please sign in to comment.