Skip to content

Commit 812e09d

Browse files
committed
Fix false-positive validation error for unknown type
Fixes #255
1 parent 32a5492 commit 812e09d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/validation/__tests__/KnownTypeNames.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,26 @@ describe('Validate: Known type names', () => {
5555
]);
5656
});
5757

58+
it('ignores type definitions', () => {
59+
expectFailsRule(KnownTypeNames, `
60+
type NotInTheSchema {
61+
field: FooBar
62+
}
63+
interface FooBar {
64+
field: NotInTheSchema
65+
}
66+
union U = A | B
67+
input Blob {
68+
field: UnknownType
69+
}
70+
query Foo($var: NotInTheSchema) {
71+
user(id: $var) {
72+
id
73+
}
74+
}
75+
`, [
76+
unknownType('NotInTheSchema', 12, 23),
77+
]);
78+
});
79+
5880
});

src/validation/rules/KnownTypeNames.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ export function unknownTypeMessage(type: any): string {
2424
*/
2525
export function KnownTypeNames(context: ValidationContext): any {
2626
return {
27+
// TODO: when validating IDL, re-enable these. Experimental version does not
28+
// add unreferenced types, resulting in false-positive errors. Squelched
29+
// errors for now.
30+
ObjectTypeDefinition: () => false,
31+
InterfaceTypeDefinition: () => false,
32+
UnionTypeDefinition: () => false,
33+
InputObjectTypeDefinition: () => false,
2734
NamedType(node) {
2835
var typeName = node.name.value;
2936
var type = context.getSchema().getType(typeName);

0 commit comments

Comments
 (0)