GraphQlView: Do not 'instantiate_middleware' if middleware is already a MiddlewareManager (#952)

This commit is contained in:
Marc Simon 2020-05-09 13:15:16 +02:00 committed by GitHub
parent 894c564ab7
commit 975f45ed1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@ from graphql.error import format_error as format_graphql_error
from graphql.error import GraphQLError from graphql.error import GraphQLError
from graphql.execution import ExecutionResult from graphql.execution import ExecutionResult
from graphql.type.schema import GraphQLSchema from graphql.type.schema import GraphQLSchema
from graphql.execution.middleware import MiddlewareManager
from .settings import graphene_settings from .settings import graphene_settings
@ -86,6 +87,9 @@ class GraphQLView(View):
self.schema = self.schema or schema self.schema = self.schema or schema
if middleware is not None: if middleware is not None:
if isinstance(middleware, MiddlewareManager):
self.middleware = middleware
else:
self.middleware = list(instantiate_middleware(middleware)) self.middleware = list(instantiate_middleware(middleware))
self.executor = executor self.executor = executor
self.root_value = root_value self.root_value = root_value