Skip to content

Commit 918b590

Browse files
committed
Enable customizing validate max_errors through settings
1 parent f889000 commit 918b590

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

docs/settings.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,14 @@ Default: ``False``
269269
270270
271271
.. _GraphiQLDocs: https://graphiql-test.netlify.app/typedoc/modules/graphiql_react#graphiqlprovider-2
272+
273+
274+
``MAX_VALIDATION_ERRORS``
275+
------------------------------------
276+
277+
In case ``validation_rules`` are provided to ``GraphQLView``, if this is set to a non-negative ``int`` value,
278+
``graphql.validation.validate`` will stop validation after this number of errors has been reached.
279+
If not set or set to ``None``, the maximum number of errors will follow ``graphql.validation.validate`` default
280+
*i.e.* 100.
281+
282+
Default: ``None``

graphene_django/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"GRAPHIQL_INPUT_VALUE_DEPRECATION": False,
4444
"ATOMIC_MUTATIONS": False,
4545
"TESTING_ENDPOINT": "/graphql",
46+
"MAX_VALIDATION_ERRORS": None,
4647
}
4748

4849
if settings.DEBUG:

graphene_django/views.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,12 @@ def execute_graphql_request(
336336
)
337337
)
338338

339-
validation_errors = validate(schema, document, self.validation_rules)
339+
validation_errors = validate(
340+
schema,
341+
document,
342+
self.validation_rules,
343+
graphene_settings.MAX_VALIDATION_ERRORS,
344+
)
340345

341346
if validation_errors:
342347
return ExecutionResult(data=None, errors=validation_errors)

0 commit comments

Comments
 (0)