Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix: Nested List Input Coercion not matching GraphQL spec #194

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
feat(Tests): Updates test to support proper nested list input coerce
  • Loading branch information
abhinand-c committed Mar 3, 2023
commit 5eb9e70777d3a4eed0717aa2075575c334490d8a
17 changes: 14 additions & 3 deletions tests/utilities/test_coerce_input_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,24 @@ def returns_null_for_a_null_value():
result = _coerce_value(None, TestNestedList)
assert expect_value(result) is None

def returns_nested_list_for_nested_non_list_values():
def returns_error_for_nested_non_list_values():
result = _coerce_value([1, 2, 3], TestNestedList)
assert expect_value(result) == [[1], [2], [3]]
assert expect_errors(result) == [
("Expected type '[Int]' to be a list.", [0], 1),
("Expected type '[Int]' to be a list.", [1], 2),
("Expected type '[Int]' to be a list.", [2], 3),
]

def returns_nested_null_for_nested_null_values():
result = _coerce_value([[None], [None]], TestNestedList)
assert expect_value(result) == [[None], [None]]

def returns_errors_for_null_values():
result = _coerce_value([42, [None], None], TestNestedList)
assert expect_value(result) == [[42], [None], None]
assert expect_errors(result) == [
("Expected type '[Int]' to be a list.", [0], 42),
("Expected type '[Int]' to be a list.", [2], None),
]

def describe_with_default_on_error():
def throw_error_without_path():
Expand Down