@@ -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
192194Creating GraphQL and GraphiQL views
193195-----------------------------------
@@ -199,6 +201,22 @@ view.
199201This view will serve as GraphQL endpoint. As we want to have the
200202aforementioned 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