mirror of
https://github.com/graphql-python/graphene-django.git
synced 2025-07-10 16:22:20 +03:00
Add missing schema validation step
This commit is contained in:
parent
b24ed31651
commit
f48d54b64c
|
@ -9,7 +9,14 @@ from django.shortcuts import render
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.csrf import ensure_csrf_cookie
|
from django.views.decorators.csrf import ensure_csrf_cookie
|
||||||
from django.views.generic import View
|
from django.views.generic import View
|
||||||
from graphql import ExecutionResult, OperationType, execute, get_operation_ast, parse
|
from graphql import (
|
||||||
|
ExecutionResult,
|
||||||
|
OperationType,
|
||||||
|
execute,
|
||||||
|
get_operation_ast,
|
||||||
|
parse,
|
||||||
|
validate_schema,
|
||||||
|
)
|
||||||
from graphql.error import GraphQLError
|
from graphql.error import GraphQLError
|
||||||
from graphql.execution.middleware import MiddlewareManager
|
from graphql.execution.middleware import MiddlewareManager
|
||||||
from graphql.language import OperationDefinitionNode
|
from graphql.language import OperationDefinitionNode
|
||||||
|
@ -296,6 +303,10 @@ class GraphQLView(View):
|
||||||
return None
|
return None
|
||||||
raise HttpError(HttpResponseBadRequest("Must provide query string."))
|
raise HttpError(HttpResponseBadRequest("Must provide query string."))
|
||||||
|
|
||||||
|
schema_validation_errors = validate_schema(self.schema.graphql_schema)
|
||||||
|
if schema_validation_errors:
|
||||||
|
return ExecutionResult(data=None, errors=schema_validation_errors)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
document = parse(query)
|
document = parse(query)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user