This commit is contained in:
Po-Hsien Chu 2017-05-06 07:35:55 +00:00 committed by GitHub
commit e1c465e9ab
2 changed files with 8 additions and 6 deletions

View File

@ -38,6 +38,9 @@ INSTALLED_APPS = [
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'graphene_django', 'graphene_django',
# a GUI for graphQL
'django_graphiql',
'cookbook.ingredients.apps.IngredientsConfig', 'cookbook.ingredients.apps.IngredientsConfig',
'cookbook.recipes.apps.RecipesConfig', 'cookbook.recipes.apps.RecipesConfig',
@ -56,6 +59,7 @@ MIDDLEWARE_CLASSES = [
GRAPHENE = { GRAPHENE = {
'SCHEMA': 'cookbook.schema.schema', 'SCHEMA': 'cookbook.schema.schema',
'SCHEMA_INDENT': 2,
'MIDDLEWARE': ( 'MIDDLEWARE': (
'graphene_django.debug.DjangoDebugMiddleware', 'graphene_django.debug.DjangoDebugMiddleware',
) )
@ -130,8 +134,3 @@ USE_TZ = True
# https://docs.djangoproject.com/en/1.9/howto/static-files/ # https://docs.djangoproject.com/en/1.9/howto/static-files/
STATIC_URL = '/static/' STATIC_URL = '/static/'
GRAPHENE = {
'SCHEMA': 'cookbook.schema.schema',
'SCHEMA_INDENT': 2,
}

View File

@ -1,9 +1,12 @@
from django.conf.urls import url from django.conf.urls import url
from django.conf.urls import include
from django.views.decorators.csrf import csrf_exempt
from django.contrib import admin from django.contrib import admin
from graphene_django.views import GraphQLView from graphene_django.views import GraphQLView
urlpatterns = [ urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^admin/', admin.site.urls),
url(r'^graphql', GraphQLView.as_view(graphiql=True)), url(r'^graphql', csrf_exempt(GraphQLView.as_view(graphiql=True))),
url(r'^graphiql', include('django_graphiql.urls')),
] ]