@@ -9,6 +9,7 @@ import type { DirectiveNode } from '../../language/ast';
9
9
import { parse } from '../../language/parser' ;
10
10
11
11
import { buildSchema } from '../../utilities/buildASTSchema' ;
12
+ import { TypeInfo } from '../../utilities/TypeInfo' ;
12
13
13
14
import { validate } from '../validate' ;
14
15
import type { ValidationContext } from '../ValidationContext' ;
@@ -57,6 +58,35 @@ describe('Validate: Supports full validation', () => {
57
58
] ) ;
58
59
} ) ;
59
60
61
+ it ( 'Deprecated: validates using a custom TypeInfo' , ( ) => {
62
+ // This TypeInfo will never return a valid field.
63
+ const typeInfo = new TypeInfo ( testSchema , null , ( ) => null ) ;
64
+
65
+ const doc = parse ( `
66
+ query {
67
+ human {
68
+ pets {
69
+ ... on Cat {
70
+ meowsVolume
71
+ }
72
+ ... on Dog {
73
+ barkVolume
74
+ }
75
+ }
76
+ }
77
+ }
78
+ ` ) ;
79
+
80
+ const errors = validate ( testSchema , doc , undefined , undefined , typeInfo ) ;
81
+ const errorMessages = errors . map ( ( error ) => error . message ) ;
82
+
83
+ expect ( errorMessages ) . to . deep . equal ( [
84
+ 'Cannot query field "human" on type "QueryRoot". Did you mean "human"?' ,
85
+ 'Cannot query field "meowsVolume" on type "Cat". Did you mean "meowsVolume"?' ,
86
+ 'Cannot query field "barkVolume" on type "Dog". Did you mean "barkVolume"?' ,
87
+ ] ) ;
88
+ } ) ;
89
+
60
90
it ( 'validates using a custom rule' , ( ) => {
61
91
const schema = buildSchema ( `
62
92
directive @custom(arg: String) on FIELD
0 commit comments