mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-24 18:44:08 +03:00
feb7252b8a
* Add support for validation rules * Enable customizing validate max_errors through settings * Add tests for validation rules * Add examples for validation rules * Allow setting validation_rules in class def * Add tests for validation_rules inherited from parent class * Make tests for validation rules stricter
30 lines
919 B
ReStructuredText
30 lines
919 B
ReStructuredText
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()),
|
|
]
|