From 34f3c72da667849943648c925b07d28d68204119 Mon Sep 17 00:00:00 2001 From: Syrus Akbary Date: Tue, 20 Sep 2016 00:08:14 -0700 Subject: [PATCH] Updated middleware view management --- graphene_django/debug/tests/test_query.py | 16 ++++++++-------- graphene_django/views.py | 5 ++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/graphene_django/debug/tests/test_query.py b/graphene_django/debug/tests/test_query.py index 87e9628..e0851e7 100644 --- a/graphene_django/debug/tests/test_query.py +++ b/graphene_django/debug/tests/test_query.py @@ -59,8 +59,8 @@ def test_should_query_field(): }] } } - schema = graphene.Schema(query=Query, middlewares=[DjangoDebugMiddleware()]) - result = schema.execute(query, context_value=context()) + schema = graphene.Schema(query=Query) + result = schema.execute(query, context_value=context(), middleware=[DjangoDebugMiddleware()]) assert not result.errors assert result.data == expected @@ -108,8 +108,8 @@ def test_should_query_list(): }] } } - schema = graphene.Schema(query=Query, middlewares=[DjangoDebugMiddleware()]) - result = schema.execute(query, context_value=context()) + schema = graphene.Schema(query=Query) + result = schema.execute(query, context_value=context(), middleware=[DjangoDebugMiddleware()]) assert not result.errors assert result.data == expected @@ -158,8 +158,8 @@ def test_should_query_connection(): }] }, } - schema = graphene.Schema(query=Query, middlewares=[DjangoDebugMiddleware()]) - result = schema.execute(query, context_value=context()) + schema = graphene.Schema(query=Query) + result = schema.execute(query, context_value=context(), middleware=[DjangoDebugMiddleware()]) assert not result.errors assert result.data['allReporters'] == expected['allReporters'] assert 'COUNT' in result.data['__debug']['sql'][0]['rawSql'] @@ -216,8 +216,8 @@ def test_should_query_connectionfilter(): }] }, } - schema = graphene.Schema(query=Query, middlewares=[DjangoDebugMiddleware()]) - result = schema.execute(query, context_value=context()) + schema = graphene.Schema(query=Query) + result = schema.execute(query, context_value=context(), middleware=[DjangoDebugMiddleware()]) assert not result.errors assert result.data['allReporters'] == expected['allReporters'] assert 'COUNT' in result.data['__debug']['sql'][0]['rawSql'] diff --git a/graphene_django/views.py b/graphene_django/views.py index 27a27df..cec3aab 100644 --- a/graphene_django/views.py +++ b/graphene_django/views.py @@ -14,7 +14,6 @@ from graphql import Source, execute, parse, validate from graphql.error import format_error as format_graphql_error from graphql.error import GraphQLError from graphql.execution import ExecutionResult -from graphql.execution.middleware import MiddlewareManager from graphql.type.schema import GraphQLSchema from graphql.utils.get_operation_ast import get_operation_ast @@ -73,7 +72,7 @@ class GraphQLView(View): self.schema = schema if middleware is not None: - self.middleware = MiddlewareManager(*list(instantiate_middleware(middleware))) + self.middleware = list(instantiate_middleware(middleware)) self.executor = executor self.root_value = root_value self.pretty = pretty @@ -220,7 +219,7 @@ class GraphQLView(View): variable_values=variables, operation_name=operation_name, context_value=self.get_context(request), - middlewares=self.get_middleware(request), + middleware=self.get_middleware(request), executor=self.executor, ) except Exception as e: