Skip to content

Commit 2c8728e

Browse files
committed
Revert the removal of the _value postfix (#234)
This restores the `_value(s)` prefix of three parameters of the execute() and graphql() functions, which had been removed in v2.1, in order to be compatible with graphql-core-next (v3), graphql-js, and the older versions again. The prefix-less parameters are still accepted, but now produce deprecation warnings (in v2.1 it was the other way around).
1 parent 4dc39aa commit 2c8728e

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

graphql/execution/executor.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ def subscribe(*args, **kwargs):
5959
def execute(
6060
schema, # type: GraphQLSchema
6161
document_ast, # type: Document
62-
root=None, # type: Any
63-
context=None, # type: Optional[Any]
64-
variables=None, # type: Optional[Any]
62+
root_value=None, # type: Any
63+
context_value=None, # type: Optional[Any]
64+
variable_values=None, # type: Optional[Any]
6565
operation_name=None, # type: Optional[str]
6666
executor=None, # type: Any
6767
return_promise=False, # type: bool
@@ -71,27 +71,27 @@ def execute(
7171
):
7272
# type: (...) -> Union[ExecutionResult, Promise[ExecutionResult]]
7373

74-
if root is None and "root_value" in options:
74+
if root_value is None and "root" in options:
7575
warnings.warn(
76-
"root_value has been deprecated. Please use root=... instead.",
76+
"The 'root' alias has been deprecated. Please use 'root_value' instead.",
7777
category=DeprecationWarning,
7878
stacklevel=2,
7979
)
80-
root = options["root_value"]
81-
if context is None and "context_value" in options:
80+
root_value = options["root"]
81+
if context_value is None and "context" in options:
8282
warnings.warn(
83-
"context_value has been deprecated. Please use context=... instead.",
83+
"The 'context' alias has been deprecated. Please use 'context_value' instead.",
8484
category=DeprecationWarning,
8585
stacklevel=2,
8686
)
87-
context = options["context_value"]
88-
if variables is None and "variable_values" in options:
87+
context_value = options["context"]
88+
if variable_values is None and "variables" in options:
8989
warnings.warn(
90-
"variable_values has been deprecated. Please use variables=... instead.",
90+
"The 'variables' alias has been deprecated. Please use 'variable_values' instead.",
9191
category=DeprecationWarning,
9292
stacklevel=2,
9393
)
94-
variables = options["variable_values"]
94+
variable_values = options["variables"]
9595
assert schema, "Must provide schema"
9696
assert isinstance(schema, GraphQLSchema), (
9797
"Schema must be an instance of GraphQLSchema. Also ensure that there are "
@@ -113,9 +113,9 @@ def execute(
113113
exe_context = ExecutionContext(
114114
schema,
115115
document_ast,
116-
root,
117-
context,
118-
variables or {},
116+
root_value,
117+
context_value,
118+
variable_values or {},
119119
operation_name,
120120
executor,
121121
middleware,
@@ -124,7 +124,7 @@ def execute(
124124

125125
def promise_executor(v):
126126
# type: (Optional[Any]) -> Union[Dict, Promise[Dict], Observable]
127-
return execute_operation(exe_context, exe_context.operation, root)
127+
return execute_operation(exe_context, exe_context.operation, root_value)
128128

129129
def on_rejected(error):
130130
# type: (Exception) -> None

graphql/graphql.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def graphql(*args, **kwargs):
4747
def execute_graphql(
4848
schema, # type: GraphQLSchema
4949
request_string="", # type: Union[Document, str]
50-
root=None, # type: Any
51-
context=None, # type: Optional[Any]
52-
variables=None, # type: Optional[Any]
50+
root_value=None, # type: Any
51+
context_value=None, # type: Optional[Any]
52+
variable_values=None, # type: Optional[Any]
5353
operation_name=None, # type: Optional[Any]
5454
middleware=None, # type: Optional[Any]
5555
backend=None, # type: Optional[Any]
@@ -62,10 +62,10 @@ def execute_graphql(
6262

6363
document = backend.document_from_string(schema, request_string)
6464
return document.execute(
65-
root=root,
66-
context=context,
65+
root_value,
66+
context_value,
6767
operation_name=operation_name,
68-
variables=variables,
68+
variable_values=variable_values,
6969
middleware=middleware,
7070
**execute_options
7171
)

0 commit comments

Comments
 (0)