Skip to content

Commit dd07cb1

Browse files
authored
Merge pull request #56 from dukebody/graphqlview-schema-explicit
Explain alternative way to specify schema in tutorial.
2 parents bb0b4fa + e72f6b2 commit dd07cb1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/tutorial.rst

+19-1
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ And then add the ``SCHEMA`` to the ``GRAPHENE`` config in ``cookbook/settings.py
188188
'SCHEMA': 'cookbook.schema.schema'
189189
}
190190
191+
Alternatively, we can specify the schema to be used in the urls definition,
192+
as explained below.
191193

192194
Creating GraphQL and GraphiQL views
193195
-----------------------------------
@@ -199,6 +201,22 @@ view.
199201
This view will serve as GraphQL endpoint. As we want to have the
200202
aforementioned GraphiQL we specify that on the params with ``graphiql=True``.
201203

204+
.. code:: python
205+
206+
from django.conf.urls import url, include
207+
from django.contrib import admin
208+
209+
from graphene_django.views import GraphQLView
210+
211+
urlpatterns = [
212+
url(r'^admin/', admin.site.urls),
213+
url(r'^graphql', GraphQLView.as_view(graphiql=True)),
214+
]
215+
216+
217+
If we didn't specify the target schema in the Django settings file
218+
as explained above, we can do so here using:
219+
202220
.. code:: python
203221
204222
from django.conf.urls import url, include
@@ -210,7 +228,7 @@ aforementioned GraphiQL we specify that on the params with ``graphiql=True``.
210228
211229
urlpatterns = [
212230
url(r'^admin/', admin.site.urls),
213-
url(r'^graphql', GraphQLView.as_view(graphiql=True)),
231+
url(r'^graphql', GraphQLView.as_view(graphiql=True, schema=schema)),
214232
]
215233
216234
Apply model changes to database

0 commit comments

Comments
 (0)