From e72f6b2610a6a6af1b5ae709a9019d2aa83334ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Israel=20Saeta=20P=C3=A9rez?= Date: Sat, 12 Nov 2016 20:08:01 +0100 Subject: [PATCH] Explain alternative way to specify schema in tutorial. --- docs/tutorial.rst | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/tutorial.rst b/docs/tutorial.rst index e4a54a7..e1537a3 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -188,6 +188,8 @@ And then add the ``SCHEMA`` to the ``GRAPHENE`` config in ``cookbook/settings.py 'SCHEMA': 'cookbook.schema.schema' } +Alternatively, we can specify the schema to be used in the urls definition, +as explained below. Creating GraphQL and GraphiQL views ----------------------------------- @@ -199,6 +201,22 @@ view. This view will serve as GraphQL endpoint. As we want to have the aforementioned GraphiQL we specify that on the params with ``graphiql=True``. +.. code:: python + + from django.conf.urls import url, include + from django.contrib import admin + + from graphene_django.views import GraphQLView + + urlpatterns = [ + url(r'^admin/', admin.site.urls), + url(r'^graphql', GraphQLView.as_view(graphiql=True)), + ] + + +If we didn't specify the target schema in the Django settings file +as explained above, we can do so here using: + .. code:: python from django.conf.urls import url, include @@ -210,7 +228,7 @@ aforementioned GraphiQL we specify that on the params with ``graphiql=True``. urlpatterns = [ url(r'^admin/', admin.site.urls), - url(r'^graphql', GraphQLView.as_view(graphiql=True)), + url(r'^graphql', GraphQLView.as_view(graphiql=True, schema=schema)), ] Apply model changes to database