@@ -188,6 +188,8 @@ And then add the ``SCHEMA`` to the ``GRAPHENE`` config in ``cookbook/settings.py
188
188
' SCHEMA' : ' cookbook.schema.schema'
189
189
}
190
190
191
+ Alternatively, we can specify the schema to be used in the urls definition,
192
+ as explained below.
191
193
192
194
Creating GraphQL and GraphiQL views
193
195
-----------------------------------
@@ -199,6 +201,22 @@ view.
199
201
This view will serve as GraphQL endpoint. As we want to have the
200
202
aforementioned GraphiQL we specify that on the params with ``graphiql=True ``.
201
203
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
+
202
220
.. code :: python
203
221
204
222
from django.conf.urls import url, include
@@ -210,7 +228,7 @@ aforementioned GraphiQL we specify that on the params with ``graphiql=True``.
210
228
211
229
urlpatterns = [
212
230
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 )),
214
232
]
215
233
216
234
Apply model changes to database
0 commit comments