Skip to content

Commit 727e091

Browse files
authored
Merge pull request #819 from adamchainz/deprecated_arguments
Change deprecated execute() arguments to new ones
2 parents d728b84 + 4f2b278 commit 727e091

File tree

10 files changed

+19
-21
lines changed

10 files changed

+19
-21
lines changed

docs/execution/execute.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ For executing a query a schema, you can directly call the ``execute`` method on
1616
Context
1717
_______
1818

19-
You can pass context to a query via ``context_value``.
19+
You can pass context to a query via ``context``.
2020

2121

2222
.. code:: python
@@ -28,14 +28,14 @@ You can pass context to a query via ``context_value``.
2828
return info.context.get('name')
2929
3030
schema = graphene.Schema(Query)
31-
result = schema.execute('{ name }', context_value={'name': 'Syrus'})
31+
result = schema.execute('{ name }', context={'name': 'Syrus'})
3232
3333
3434
3535
Variables
3636
_______
3737

38-
You can pass variables to a query via ``variable_values``.
38+
You can pass variables to a query via ``variables``.
3939

4040

4141
.. code:: python
@@ -55,5 +55,5 @@ You can pass variables to a query via ``variable_values``.
5555
lastName
5656
}
5757
}''',
58-
variable_values={'id': 12},
58+
variables={'id': 12},
5959
)

docs/testing/index.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Execute parameters
5454
~~~~~~~~~~~~~~~~~~
5555

5656
You can also add extra keyword arguments to the ``execute`` method, such as
57-
``context_value``, ``root_value``, ``variable_values``, ...:
57+
``context``, ``root``, ``variables``, ...:
5858

5959

6060
.. code:: python
@@ -63,7 +63,7 @@ You can also add extra keyword arguments to the ``execute`` method, such as
6363
6464
def test_hey():
6565
client = Client(my_schema)
66-
executed = client.execute('''{ hey }''', context_value={'user': 'Peter'})
66+
executed = client.execute('''{ hey }''', context={'user': 'Peter'})
6767
assert executed == {
6868
'data': {
6969
'hey': 'hello Peter!'

examples/context_example.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ def resolve_me(self, info):
2525

2626

2727
def test_query():
28-
result = schema.execute(query, context_value={"user": User(id="1", name="Syrus")})
28+
result = schema.execute(query, context={"user": User(id="1", name="Syrus")})
2929
assert not result.errors
3030
assert result.data == {"me": {"id": "1", "name": "Syrus"}}
3131

3232

3333
if __name__ == "__main__":
34-
result = schema.execute(query, context_value={"user": User(id="X", name="Console")})
34+
result = schema.execute(query, context={"user": User(id="X", name="Console")})
3535
print(result.data["me"])

examples/starwars/tests/test_query.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_fetch_some_id_query(snapshot):
7272
}
7373
"""
7474
params = {"someId": "1000"}
75-
snapshot.assert_match(client.execute(query, variable_values=params))
75+
snapshot.assert_match(client.execute(query, variables=params))
7676

7777

7878
def test_fetch_some_id_query2(snapshot):
@@ -84,7 +84,7 @@ def test_fetch_some_id_query2(snapshot):
8484
}
8585
"""
8686
params = {"someId": "1002"}
87-
snapshot.assert_match(client.execute(query, variable_values=params))
87+
snapshot.assert_match(client.execute(query, variables=params))
8888

8989

9090
def test_invalid_id_query(snapshot):
@@ -96,7 +96,7 @@ def test_invalid_id_query(snapshot):
9696
}
9797
"""
9898
params = {"id": "not a valid id"}
99-
snapshot.assert_match(client.execute(query, variable_values=params))
99+
snapshot.assert_match(client.execute(query, variables=params))
100100

101101

102102
def test_fetch_luke_aliased(snapshot):

graphene/types/tests/test_datetime.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_datetime_query_variable():
9090

9191
result = schema.execute(
9292
"""query Test($date: DateTime){ datetime(in: $date) }""",
93-
variable_values={"date": isoformat},
93+
variables={"date": isoformat},
9494
)
9595
assert not result.errors
9696
assert result.data == {"datetime": isoformat}
@@ -101,8 +101,7 @@ def test_date_query_variable():
101101
isoformat = now.isoformat()
102102

103103
result = schema.execute(
104-
"""query Test($date: Date){ date(in: $date) }""",
105-
variable_values={"date": isoformat},
104+
"""query Test($date: Date){ date(in: $date) }""", variables={"date": isoformat}
106105
)
107106
assert not result.errors
108107
assert result.data == {"date": isoformat}
@@ -114,8 +113,7 @@ def test_time_query_variable():
114113
isoformat = time.isoformat()
115114

116115
result = schema.execute(
117-
"""query Test($time: Time){ time(at: $time) }""",
118-
variable_values={"time": isoformat},
116+
"""query Test($time: Time){ time(at: $time) }""", variables={"time": isoformat}
119117
)
120118
assert not result.errors
121119
assert result.data == {"time": isoformat}

graphene/types/tests/test_decimal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_decimal_string_query_variable():
2828

2929
result = schema.execute(
3030
"""query Test($decimal: Decimal){ decimal(input: $decimal) }""",
31-
variable_values={"decimal": decimal_value},
31+
variables={"decimal": decimal_value},
3232
)
3333
assert not result.errors
3434
assert result.data == {"decimal": str(decimal_value)}

graphene/types/tests/test_generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test_generic_query_variable():
3939
]:
4040
result = schema.execute(
4141
"""query Test($generic: GenericScalar){ generic(input: $generic) }""",
42-
variable_values={"generic": generic_value},
42+
variables={"generic": generic_value},
4343
)
4444
assert not result.errors
4545
assert result.data == {"generic": generic_value}

graphene/types/tests/test_json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_jsonstring_query_variable():
2828

2929
result = schema.execute(
3030
"""query Test($json: JSONString){ json(input: $json) }""",
31-
variable_values={"json": json_value},
31+
variables={"json": json_value},
3232
)
3333
assert not result.errors
3434
assert result.data == {"json": json_value}

graphene/types/tests/test_query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def resolve_info(self, info):
464464
assert not result.errors
465465
assert result.data == {"annotated": "base-self"}
466466

467-
result = test_schema.execute("{ context }", "base", context_value=context)
467+
result = test_schema.execute("{ context }", "base", context=context)
468468
assert not result.errors
469469
assert result.data == {"context": "base-context"}
470470

graphene/types/tests/test_uuid.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def test_uuidstring_query_variable():
2525

2626
result = schema.execute(
2727
"""query Test($uuid: UUID){ uuid(input: $uuid) }""",
28-
variable_values={"uuid": uuid_value},
28+
variables={"uuid": uuid_value},
2929
)
3030
assert not result.errors
3131
assert result.data == {"uuid": uuid_value}

0 commit comments

Comments
 (0)