Skip to content

Commit 45e9ebe

Browse files
committed
fix(List Input Coercion): Adds validation code for nested list with multiple values
1 parent e171a14 commit 45e9ebe

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/utilities/coerceInputValue.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,21 @@ function coerceInputValueImpl(
7676
if (isListType(type)) {
7777
const itemType = type.ofType;
7878
if (isIterableObject(inputValue)) {
79+
const isNestedList = Boolean(
80+
isListType(itemType) && Array.from(inputValue).length > 1,
81+
);
7982
return Array.from(inputValue, (itemValue, index) => {
8083
const itemPath = addPath(path, index, undefined);
84+
if (isNestedList && !isIterableObject(itemValue)) {
85+
// Input values should be iterable for nested list type with multiple values
86+
onError(
87+
pathToArray(itemPath),
88+
itemValue,
89+
new GraphQLError(
90+
`Expected type "${inspect(itemType)}" to be a list.`,
91+
),
92+
);
93+
}
8194
return coerceInputValueImpl(itemValue, itemType, onError, itemPath);
8295
});
8396
}

0 commit comments

Comments
 (0)