Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename op_name to operation_name #941

Merged
merged 3 commits into from
May 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions graphene_django/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_camelize():
@patch("graphene_django.utils.testing.Client.post")
def test_graphql_test_case_op_name(post_mock):
"""
Test that `GraphQLTestCase.query()`'s `op_name` argument produces an `operationName` field.
Test that `GraphQLTestCase.query()`'s `operation_name` argument produces an `operationName` field.
"""

class TestClass(GraphQLTestCase):
Expand All @@ -51,7 +51,7 @@ def runTest(self):

tc = TestClass()
tc.setUpClass()
tc.query("query { }", op_name="QueryName")
tc.query("query { }", operation_name="QueryName")
body = json.loads(post_mock.call_args.args[1])
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
assert (
Expand Down
10 changes: 6 additions & 4 deletions graphene_django/utils/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,13 @@ def setUpClass(cls):

cls._client = Client()

def query(self, query, op_name=None, input_data=None, variables=None, headers=None):
def query(
self, query, operation_name=None, input_data=None, variables=None, headers=None
):
"""
Args:
query (string) - GraphQL query to run
op_name (string) - If the query is a mutation or named query, you must
operation_name (string) - If the query is a mutation or named query, you must
supply the op_name. For annon queries ("{ ... }"),
should be None (default).
input_data (dict) - If provided, the $input variable in GraphQL will be set
Expand All @@ -44,8 +46,8 @@ def query(self, query, op_name=None, input_data=None, variables=None, headers=No
Response object from client
"""
body = {"query": query}
if op_name:
body["operationName"] = op_name
if operation_name:
body["operationName"] = operation_name
if variables:
body["variables"] = variables
if input_data:
Expand Down