This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # djr/ | |
| # create app with the name gql | |
| # (name is not necessarily to be gql) | |
| python manage.py startapp gql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.contrib import admin | |
| from django.urls import path | |
| from graphene_django.views import GraphQLView | |
| from django.views.decorators.csrf import csrf_exempt | |
| from django.views.generic import TemplateView | |
| urlpatterns = [ | |
| path('admin/', admin.site.urls), | |
| # apiclient on client-side will request this adress later |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # djr/djr/settings.py | |
| GRAPHENE = { | |
| 'SCHEMA': 'gql.schema.schema' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graphene | |
| from items.models import Movie | |
| from graphene_django.types import DjangoObjectType | |
| # api-movie-model | |
| class MovieType(DjangoObjectType): | |
| id = graphene.Int() | |
| name = graphene.String() | |
| year = graphene.Int() | |
| summary = graphene.String() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| query { | |
| #the query name | |
| movieList{ | |
| # the fields which we will request | |
| id, | |
| name, | |
| posterUrl, #camelCase | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| query { | |
| #the query and argument | |
| movie(slug:"the-matrix-1999"){ | |
| # the fields which we will request | |
| id, | |
| name, | |
| posterUrl, #camelCase | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #<---Install python 3.8---> | |
| cd /opt | |
| sudo wget <https://www.python.org/ftp/python/3.8.0/Python-3.8.0.tgz> | |
| #extract the source | |
| sudo tar xzf Python-3.8.0.tgz | |
| cd Python-3.8.0 | |
| sudo ./configure --enable-loadable-sqlite-extensions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # <--- Create Django Project ---> | |
| # We will create the project in the Blog folder | |
| # with a name djr | |
| # install our dependencies | |
| pip install ipython django django_extensions django-cors-headers "graphene-django>=2.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #start a django project | |
| django-admin startproject djr | |
| # change directory | |
| cd djr | |
| # create templates directory | |
| mkdir templates | |
| # create static folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # create our app and activate it on the settings.py | |
| python manage.py startapp items |
OlderNewer