Skip to content

Commit 036f026

Browse files
committed
Add support for execution_context_class in webob
1 parent 26fdc4f commit 036f026

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

graphql_server/webob/graphqlview.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class GraphQLView:
3636
graphiql_html_title = None
3737
middleware = None
3838
validation_rules = None
39+
execution_context_class = None
3940
batch = False
4041
enable_async = False
4142
subscriptions = None
@@ -81,6 +82,9 @@ def get_validation_rules(self):
8182
return specified_rules
8283
return self.validation_rules
8384

85+
def get_execution_context_class(self):
86+
return self.execution_context_class
87+
8488
def dispatch_request(self, request):
8589
try:
8690
request_method = request.method.lower()
@@ -107,6 +111,7 @@ def dispatch_request(self, request):
107111
context_value=self.get_context(request),
108112
middleware=self.get_middleware(),
109113
validation_rules=self.get_validation_rules(),
114+
execution_context_class=self.get_execution_context_class(),
110115
)
111116
result, status_code = encode_execution_results(
112117
execution_results,

tests/webob/test_graphqlview.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import pytest
55

6+
from ..utils import RepeatExecutionContext
67
from .app import Client, url_string
78

89

@@ -563,3 +564,17 @@ def test_batch_allows_post_with_operation_name(client, settings):
563564
"data": {"test": "Hello World", "shared": "Hello Everyone"}
564565
}
565566
]
567+
568+
569+
@pytest.mark.parametrize(
570+
"settings", [dict(execution_context_class=RepeatExecutionContext)]
571+
)
572+
def test_custom_execution_context_class(client):
573+
response = client.post(
574+
url_string(),
575+
data=json_dump_kwarg(query="{test}"),
576+
content_type="application/json",
577+
)
578+
579+
assert response.status_code == 200
580+
assert response_json(response) == {"data": {"test": "Hello WorldHello World"}}

0 commit comments

Comments
 (0)