fix order_by snake casing by checking if value is None, switch executor to execution_context_class since schema.execute no longer supports executor

This commit is contained in:
Jason Kraus 2020-12-30 15:30:42 -08:00
parent ac8aaf8525
commit 81d167a290
3 changed files with 6 additions and 6 deletions

View File

@ -66,7 +66,7 @@ class DjangoFilterConnectionField(DjangoConnectionField):
kwargs = {} kwargs = {}
for k, v in args.items(): for k, v in args.items():
if k in filtering_args: if k in filtering_args:
if k == "order_by": if k == "order_by" and v is not None:
v = to_snake_case(v) v = to_snake_case(v)
kwargs[k] = v kwargs[k] = v
return kwargs return kwargs

View File

@ -1224,7 +1224,7 @@ def test_filter_filterset_based_on_mixin():
} }
} }
result = schema.execute(query, variable_values={"email": reporter_1.email}) result = schema.execute(query, variable_values={"email": reporter_1.email},)
assert not result.errors assert not result.errors
assert result.data == expected assert result.data == expected

View File

@ -94,6 +94,7 @@ class GraphQLView(View):
pretty=False, pretty=False,
batch=False, batch=False,
subscription_path=None, subscription_path=None,
execution_context_class=None,
): ):
if not schema: if not schema:
schema = graphene_settings.SCHEMA schema = graphene_settings.SCHEMA
@ -111,6 +112,7 @@ class GraphQLView(View):
self.pretty = self.pretty or pretty self.pretty = self.pretty or pretty
self.graphiql = self.graphiql or graphiql self.graphiql = self.graphiql or graphiql
self.batch = self.batch or batch self.batch = self.batch or batch
self.execution_context_class = execution_context_class
if subscription_path is None: if subscription_path is None:
self.subscription_path = graphene_settings.SUBSCRIPTION_PATH self.subscription_path = graphene_settings.SUBSCRIPTION_PATH
@ -307,10 +309,8 @@ class GraphQLView(View):
try: try:
extra_options = {} extra_options = {}
if getattr(self, "executor", None): if self.execution_context_class:
# We only include it optionally since extra_options["execution_context_class"] = self.execution_context_class
# executor is not a valid argument in all backends
extra_options["executor"] = self.executor
options = { options = {
"source": query, "source": query,