Skip to content

Commit f889000

Browse files
committed
Add support for validation rules
1 parent e735f5d commit f889000

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

graphene_django/views.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class GraphQLView(View):
9696
batch = False
9797
subscription_path = None
9898
execution_context_class = None
99+
validation_rules = None
99100

100101
def __init__(
101102
self,
@@ -107,6 +108,7 @@ def __init__(
107108
batch=False,
108109
subscription_path=None,
109110
execution_context_class=None,
111+
validation_rules=None,
110112
):
111113
if not schema:
112114
schema = graphene_settings.SCHEMA
@@ -135,6 +137,8 @@ def __init__(
135137
), "A Schema is required to be provided to GraphQLView."
136138
assert not all((graphiql, batch)), "Use either graphiql or batch processing"
137139

140+
self.validation_rules = validation_rules
141+
138142
# noinspection PyUnusedLocal
139143
def get_root_value(self, request):
140144
return self.root_value
@@ -332,7 +336,7 @@ def execute_graphql_request(
332336
)
333337
)
334338

335-
validation_errors = validate(schema, document)
339+
validation_errors = validate(schema, document, self.validation_rules)
336340

337341
if validation_errors:
338342
return ExecutionResult(data=None, errors=validation_errors)

0 commit comments

Comments
 (0)