Skip to content

Commit 1922ab7

Browse files
committed
Restore variable own-property checks in valueFromAST
1 parent 0ccc1a5 commit 1922ab7

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎tests/utilities/test_value_from_ast.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,16 @@ def accepts_variable_values_assuming_already_coerced():
214214
assert _value_from("$var", GraphQLBoolean, {"var": True}) is True
215215
assert _value_from("$var", GraphQLBoolean, {"var": None}) is None
216216
assert _value_from("$var", non_null_bool, {"var": None}) is Undefined
217+
# Python dicts have no prototype chain, so an inherited attribute name
218+
# is just a missing key, and an explicit Undefined value is missing too.
219+
assert _value_from("$toString", GraphQLBoolean, {}) is Undefined
220+
assert _value_from("$var", GraphQLBoolean, {"var": Undefined}) is Undefined
217221

218222
def asserts_variables_are_provided_as_items_in_lists():
219223
assert _value_from("[ $foo ]", list_of_bool, {}) == [None]
224+
assert _value_from("[ $foo ]", list_of_bool, {"foo": Undefined}) == [None]
220225
assert _value_from("[ $foo ]", list_of_non_null_bool, {}) is Undefined
226+
assert _value_from("[ $toString ]", list_of_bool, {}) == [None]
221227
assert _value_from("[ $foo ]", list_of_non_null_bool, {"foo": True}) == [True]
222228
# Note: variables are expected to have already been coerced, so we
223229
# do not expect the singleton wrapping behavior for variables.
@@ -233,6 +239,9 @@ def omits_input_object_fields_for_unprovided_variables():
233239
"int": 42,
234240
"requiredBool": True,
235241
}
242+
assert _value_from(
243+
"{ int: $toString, requiredBool: true }", test_input_obj, {}
244+
) == {"int": 42, "requiredBool": True}
236245

237246
def transforms_names_using_out_name():
238247
# This is an extension of GraphQL.js.

0 commit comments

Comments
 (0)