mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-22 09:37:07 +03:00
Updated middleware view management
This commit is contained in:
parent
317c8ceec4
commit
34f3c72da6
|
@ -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']
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user