mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-04-12 13:14:23 +03:00
Add support for validation rules
This commit is contained in:
parent
e735f5dbdb
commit
f88900017d
|
@ -96,6 +96,7 @@ class GraphQLView(View):
|
|||
batch = False
|
||||
subscription_path = None
|
||||
execution_context_class = None
|
||||
validation_rules = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -107,6 +108,7 @@ class GraphQLView(View):
|
|||
batch=False,
|
||||
subscription_path=None,
|
||||
execution_context_class=None,
|
||||
validation_rules=None,
|
||||
):
|
||||
if not schema:
|
||||
schema = graphene_settings.SCHEMA
|
||||
|
@ -135,6 +137,8 @@ class GraphQLView(View):
|
|||
), "A Schema is required to be provided to GraphQLView."
|
||||
assert not all((graphiql, batch)), "Use either graphiql or batch processing"
|
||||
|
||||
self.validation_rules = validation_rules
|
||||
|
||||
# noinspection PyUnusedLocal
|
||||
def get_root_value(self, request):
|
||||
return self.root_value
|
||||
|
@ -332,7 +336,7 @@ class GraphQLView(View):
|
|||
)
|
||||
)
|
||||
|
||||
validation_errors = validate(schema, document)
|
||||
validation_errors = validate(schema, document, self.validation_rules)
|
||||
|
||||
if validation_errors:
|
||||
return ExecutionResult(data=None, errors=validation_errors)
|
||||
|
|
Loading…
Reference in New Issue
Block a user