Skip to content

Commit cf2f10f

Browse files
committed
VariablesAreInputTypesRule: add test for ignoring unknown types
Replicates graphql/graphql-js@ac8f0c6
1 parent 4290500 commit cf2f10f

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

src/graphql/validation/rules/variables_are_input_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def enter_variable_definition(
2222
type_ = type_from_ast(self.context.schema, node.type)
2323

2424
# If the variable type is not an input type, return an error.
25-
if type_ and not is_input_type(type_):
25+
if type_ is not None and not is_input_type(type_):
2626
variable_name = node.variable.name.value
2727
type_name = print_ast(node.type)
2828
self.report_error(

tests/validation/test_known_type_names.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def known_type_names_are_valid():
3737
def unknown_type_names_are_invalid():
3838
assert_errors(
3939
"""
40-
query Foo($var: JumbledUpLetters) {
40+
query Foo($var: [JumbledUpLetters!]!) {
4141
user(id: 4) {
4242
name
4343
pets { ... on Badger { name }, ...PetFields, ... { name } }
@@ -50,7 +50,7 @@ def unknown_type_names_are_invalid():
5050
[
5151
{
5252
"message": "Unknown type 'JumbledUpLetters'.",
53-
"locations": [(2, 29)],
53+
"locations": [(2, 30)],
5454
},
5555
{"message": "Unknown type 'Badger'.", "locations": [(5, 31)]},
5656
{

tests/validation/test_variables_are_input_types.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@
1010

1111

1212
def describe_validate_variables_are_input_types():
13+
def unknown_types_are_ignored():
14+
assert_valid(
15+
"""
16+
query Foo($a: Unknown, $b: [[Unknown!]]!) {
17+
field(a: $a, b: $b)
18+
}
19+
"""
20+
)
21+
1322
def input_types_are_valid():
1423
assert_valid(
1524
"""

0 commit comments

Comments
 (0)