mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-11-10 19:57:15 +03:00
Rename op_name to operation_name (#941)
This commit is contained in:
parent
10d22de98e
commit
07c51092e1
|
@ -40,7 +40,7 @@ def test_camelize():
|
||||||
@patch("graphene_django.utils.testing.Client.post")
|
@patch("graphene_django.utils.testing.Client.post")
|
||||||
def test_graphql_test_case_op_name(post_mock):
|
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):
|
class TestClass(GraphQLTestCase):
|
||||||
|
@ -51,7 +51,7 @@ def test_graphql_test_case_op_name(post_mock):
|
||||||
|
|
||||||
tc = TestClass()
|
tc = TestClass()
|
||||||
tc.setUpClass()
|
tc.setUpClass()
|
||||||
tc.query("query { }", op_name="QueryName")
|
tc.query("query { }", operation_name="QueryName")
|
||||||
body = json.loads(post_mock.call_args.args[1])
|
body = json.loads(post_mock.call_args.args[1])
|
||||||
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
|
# `operationName` field from https://graphql.org/learn/serving-over-http/#post-request
|
||||||
assert (
|
assert (
|
||||||
|
|
|
@ -24,11 +24,13 @@ class GraphQLTestCase(TestCase):
|
||||||
|
|
||||||
cls._client = Client()
|
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:
|
Args:
|
||||||
query (string) - GraphQL query to run
|
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 ("{ ... }"),
|
supply the op_name. For annon queries ("{ ... }"),
|
||||||
should be None (default).
|
should be None (default).
|
||||||
input_data (dict) - If provided, the $input variable in GraphQL will be set
|
input_data (dict) - If provided, the $input variable in GraphQL will be set
|
||||||
|
@ -44,8 +46,8 @@ class GraphQLTestCase(TestCase):
|
||||||
Response object from client
|
Response object from client
|
||||||
"""
|
"""
|
||||||
body = {"query": query}
|
body = {"query": query}
|
||||||
if op_name:
|
if operation_name:
|
||||||
body["operationName"] = op_name
|
body["operationName"] = operation_name
|
||||||
if variables:
|
if variables:
|
||||||
body["variables"] = variables
|
body["variables"] = variables
|
||||||
if input_data:
|
if input_data:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user