Updated middleware view management

This commit is contained in:
Syrus Akbary 2016-09-20 00:08:14 -07:00
parent 317c8ceec4
commit 34f3c72da6
2 changed files with 10 additions and 11 deletions

View File

@ -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']

View File

@ -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: