Skip to content

Commit 8b9333a

Browse files
committed
Fixed the context option
1 parent 4183613 commit 8b9333a

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

Diff for: flask_graphql/graphqlview.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class GraphQLView(View):
2222
graphiql_template = None
2323
graphiql_html_title = None
2424
middleware = None
25+
context = None
2526
batch = False
2627

2728
methods = ['GET', 'POST', 'PUT', 'DELETE']
@@ -39,7 +40,7 @@ def get_root_value(self):
3940
return self.root_value
4041

4142
def get_context(self):
42-
return request
43+
return self.context or request
4344

4445
def get_middleware(self):
4546
return self.middleware

Diff for: tests/test_graphqlview.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ def test_passes_request_into_request_context(client):
451451
}
452452

453453

454-
@pytest.mark.parametrize('app', [create_app(get_context=lambda:"CUSTOM CONTEXT")])
454+
@pytest.mark.parametrize('app', [create_app(context="CUSTOM CONTEXT")])
455455
def test_supports_pretty_printing(client):
456456
response = client.get(url_string(query='{context}'))
457457

@@ -514,8 +514,8 @@ def test_batch_supports_post_json_query_with_json_variables(client):
514514
# 'id': 1,
515515
'data': {'test': "Hello Dolly"}
516516
}]
517-
518-
517+
518+
519519
@pytest.mark.parametrize('app', [create_app(batch=True)])
520520
def test_batch_allows_post_with_operation_name(client):
521521
response = client.post(

0 commit comments

Comments
 (0)