Skip to content

Commit 36aaa00

Browse files
committed
make sure types can default to null
1 parent d85e56e commit 36aaa00

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

graphql/utils/is_valid_literal_value.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def is_valid_literal_value(type, value_ast):
1717
if not value_ast:
1818
return _empty_list
1919

20-
if isinstance(value_ast, ast.Variable):
20+
if isinstance(value_ast, (ast.Variable, ast.NullValue)):
2121
return _empty_list
2222

2323
if isinstance(type, GraphQLList):
@@ -60,9 +60,6 @@ def get_field_ast_value(field_name):
6060

6161
assert isinstance(type, (GraphQLScalarType, GraphQLEnumType)), 'Must be input type'
6262

63-
if isinstance(value_ast, ast.NullValue):
64-
return _empty_list
65-
6663
parse_result = type.parse_literal(value_ast)
6764
if parse_result is None:
6865
return [u'Expected type "{}", found {}.'.format(type.name, print_ast(value_ast))]

graphql/validation/tests/test_default_values_of_correct_type.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def test_variables_with_valid_default_values():
4444
query WithDefaultValues(
4545
$a: Int = 1,
4646
$b: String = "ok",
47-
$c: ComplexInput = { requiredField: true, intField: 3 }
47+
$c: ComplexInput = { requiredField: true, intField: 3 },
48+
$d: ComplexInputl = null,
49+
$d: [Int] = null
4850
) {
4951
dog { name }
5052
}

0 commit comments

Comments
 (0)