Skip to content

Commit f84c3c5

Browse files
committed
fix(List Input Coercion): Adds validation for nested lists with multiple values
1 parent dd08366 commit f84c3c5

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/graphql/utilities/coerce_input_value.py

+8
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,15 @@ def coerce_input_value(
7070
if is_iterable(input_value):
7171
coerced_list: List[Any] = []
7272
append_item = coerced_list.append
73+
is_nested_list = bool(is_list_type(item_type) and len(input_value) > 1)
7374
for index, item_value in enumerate(input_value):
75+
if is_nested_list and not is_iterable(item_value):
76+
# All input values should be iterable for multivalued nested list types
77+
on_error(
78+
path.as_list() if path else Path(path, index, None).as_list(),
79+
item_value,
80+
GraphQLError(f"Expected type '{inspect(item_type)}' to be a list."),
81+
)
7482
append_item(
7583
coerce_input_value(
7684
item_value, item_type, on_error, Path(path, index, None)

0 commit comments

Comments
 (0)