diff --git a/docs/settings.rst b/docs/settings.rst index e5f0faf..79c52e2 100644 --- a/docs/settings.rst +++ b/docs/settings.rst @@ -269,3 +269,14 @@ Default: ``False`` .. _GraphiQLDocs: https://graphiql-test.netlify.app/typedoc/modules/graphiql_react#graphiqlprovider-2 + + +``MAX_VALIDATION_ERRORS`` +------------------------------------ + +In case ``validation_rules`` are provided to ``GraphQLView``, if this is set to a non-negative ``int`` value, +``graphql.validation.validate`` will stop validation after this number of errors has been reached. +If not set or set to ``None``, the maximum number of errors will follow ``graphql.validation.validate`` default +*i.e.* 100. + +Default: ``None`` diff --git a/graphene_django/settings.py b/graphene_django/settings.py index de2c521..f7e3ee7 100644 --- a/graphene_django/settings.py +++ b/graphene_django/settings.py @@ -43,6 +43,7 @@ DEFAULTS = { "GRAPHIQL_INPUT_VALUE_DEPRECATION": False, "ATOMIC_MUTATIONS": False, "TESTING_ENDPOINT": "/graphql", + "MAX_VALIDATION_ERRORS": None, } if settings.DEBUG: diff --git a/graphene_django/views.py b/graphene_django/views.py index 2cb8827..fca9194 100644 --- a/graphene_django/views.py +++ b/graphene_django/views.py @@ -336,7 +336,12 @@ class GraphQLView(View): ) ) - validation_errors = validate(schema, document, self.validation_rules) + validation_errors = validate( + schema, + document, + self.validation_rules, + graphene_settings.MAX_VALIDATION_ERRORS, + ) if validation_errors: return ExecutionResult(data=None, errors=validation_errors)