Skip to content

Commit 12800cd

Browse files
committed
Fix false-positive validation error for unknown type
Related GraphQL-js commit: graphql/graphql-js@812e09d
1 parent 649344e commit 12800cd

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

graphql/core/validation/rules/known_type_names.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@
44

55
class KnownTypeNames(ValidationRule):
66

7+
def enter_ObjectTypeDefinition(self, node, *args):
8+
return False
9+
10+
def enter_InterfaceTypeDefinition(self, node, *args):
11+
return False
12+
13+
def enter_UnionTypeDefinition(self, node, *args):
14+
return False
15+
16+
def enter_InputObjectTypeDefinition(self, node, *args):
17+
return False
18+
719
def enter_NamedType(self, node, *args):
820
type_name = node.name.value
921
type = self.context.get_schema().get_type(type_name)

tests/core_validation/test_known_type_names.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,25 @@ def test_unknown_type_names_are_invalid():
3939
unknown_type('Badger', 5, 25),
4040
unknown_type('Peettt', 8, 29),
4141
])
42+
43+
44+
def test_ignores_type_definitions():
45+
expect_fails_rule(KnownTypeNames, '''
46+
type NotInTheSchema {
47+
field: FooBar
48+
}
49+
interface FooBar {
50+
field: NotInTheSchema
51+
}
52+
union U = A | B
53+
input Blob {
54+
field: UnknownType
55+
}
56+
query Foo($var: NotInTheSchema) {
57+
user(id: $var) {
58+
id
59+
}
60+
}
61+
''', [
62+
unknown_type('NotInTheSchema', 12, 23),
63+
])

0 commit comments

Comments
 (0)