mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-05 12:53:12 +03:00
Add examples for validation rules
This commit is contained in:
parent
3ca12446d7
commit
9a56a2b751
|
@ -33,5 +33,6 @@ For more advanced use, check out the Relay tutorial.
|
||||||
authorization
|
authorization
|
||||||
debug
|
debug
|
||||||
introspection
|
introspection
|
||||||
|
validation
|
||||||
testing
|
testing
|
||||||
settings
|
settings
|
||||||
|
|
29
docs/validation.rst
Normal file
29
docs/validation.rst
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
Query Validation
|
||||||
|
================
|
||||||
|
|
||||||
|
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``.
|
||||||
|
|
||||||
|
.. code:: python
|
||||||
|
|
||||||
|
from django.urls import path
|
||||||
|
from graphene.validation import DisableIntrospection
|
||||||
|
from graphene_django.views import GraphQLView
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("graphql", GraphQLView.as_view(validation_rules=(DisableIntrospection,))),
|
||||||
|
]
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
.. code:: python
|
||||||
|
|
||||||
|
from django.urls import path
|
||||||
|
from graphene.validation import DisableIntrospection
|
||||||
|
from graphene_django.views import GraphQLView
|
||||||
|
|
||||||
|
class View(GraphQLView):
|
||||||
|
validation_rules = (DisableIntrospection,)
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("graphql", View.as_view()),
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user