Skip to content

Commit 9a56a2b

Browse files
committed
Add examples for validation rules
1 parent 3ca1244 commit 9a56a2b

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Diff for: docs/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@ For more advanced use, check out the Relay tutorial.
3333
authorization
3434
debug
3535
introspection
36+
validation
3637
testing
3738
settings

Diff for: docs/validation.rst

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
Query Validation
2+
================
3+
4+
Graphene-Django supports query validation by allowing passing a list of validation rules (subclasses of `ValidationRule <https://github.com/graphql-python/graphql-core/blob/v3.2.3/src/graphql/validation/rules/__init__.py>`_ from graphql-core) to the ``validation_rules`` option in ``GraphQLView``.
5+
6+
.. code:: python
7+
8+
from django.urls import path
9+
from graphene.validation import DisableIntrospection
10+
from graphene_django.views import GraphQLView
11+
12+
urlpatterns = [
13+
path("graphql", GraphQLView.as_view(validation_rules=(DisableIntrospection,))),
14+
]
15+
16+
or
17+
18+
.. code:: python
19+
20+
from django.urls import path
21+
from graphene.validation import DisableIntrospection
22+
from graphene_django.views import GraphQLView
23+
24+
class View(GraphQLView):
25+
validation_rules = (DisableIntrospection,)
26+
27+
urlpatterns = [
28+
path("graphql", View.as_view()),
29+
]

0 commit comments

Comments
 (0)