mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-01-30 19:24:08 +03:00
Explain alternative way to specify schema in tutorial.
This commit is contained in:
parent
bb0b4fa766
commit
e72f6b2610
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user