Skip to content

Commit

Permalink
Merge pull request #123 from HorizonXP/fix-batch-response-format
Browse files Browse the repository at this point in the history
Remove payload key from response and stick to original format.
  • Loading branch information
syrusakbary authored Mar 5, 2017
2 parents 335339c + f720912 commit 1139507
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
14 changes: 6 additions & 8 deletions graphene_django/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_batch_allows_post_with_json_encoding(client):
assert response.status_code == 200
assert response_json(response) == [{
'id': 1,
'payload': { 'data': {'test': "Hello World"} },
'data': {'test': "Hello World"},
'status': 200,
}]

Expand Down Expand Up @@ -233,7 +233,7 @@ def test_batch_supports_post_json_query_with_string_variables(client):
assert response.status_code == 200
assert response_json(response) == [{
'id': 1,
'payload': { 'data': {'test': "Hello Dolly"} },
'data': {'test': "Hello Dolly"},
'status': 200,
}]

Expand All @@ -260,7 +260,7 @@ def test_batch_supports_post_json_query_with_json_variables(client):
assert response.status_code == 200
assert response_json(response) == [{
'id': 1,
'payload': { 'data': {'test': "Hello Dolly"} },
'data': {'test': "Hello Dolly"},
'status': 200,
}]

Expand Down Expand Up @@ -356,11 +356,9 @@ def test_batch_allows_post_with_operation_name(client):
assert response.status_code == 200
assert response_json(response) == [{
'id': 1,
'payload': {
'data': {
'test': 'Hello World',
'shared': 'Hello Everyone'
}
'data': {
'test': 'Hello World',
'shared': 'Hello Everyone'
},
'status': 200,
}]
Expand Down
7 changes: 2 additions & 5 deletions graphene_django/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,8 @@ def get_response(self, request, data, show_graphiql=False):
response['data'] = execution_result.data

if self.batch:
response = {
'id': id,
'payload': response,
'status': status_code,
}
response['id'] = id
response['status'] = status_code

result = self.json_encode(request, response, pretty=show_graphiql)
else:
Expand Down

0 comments on commit 1139507

Please sign in to comment.