From 9a56a2b7514a74bbc2c81f7f693abf937c594416 Mon Sep 17 00:00:00 2001 From: Kien Dang Date: Fri, 24 Nov 2023 04:50:14 +0800 Subject: [PATCH] Add examples for validation rules --- docs/index.rst | 1 + docs/validation.rst | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 docs/validation.rst diff --git a/docs/index.rst b/docs/index.rst index 373969e..df97a57 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -33,5 +33,6 @@ For more advanced use, check out the Relay tutorial. authorization debug introspection + validation testing settings diff --git a/docs/validation.rst b/docs/validation.rst new file mode 100644 index 0000000..7137342 --- /dev/null +++ b/docs/validation.rst @@ -0,0 +1,29 @@ +Query Validation +================ + +Graphene-Django supports query validation by allowing passing a list of validation rules (subclasses of `ValidationRule `_ 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()), + ]