@@ -9,6 +9,7 @@ import type { DirectiveNode } from '../../language/ast';
99import { parse } from '../../language/parser' ;
1010
1111import { buildSchema } from '../../utilities/buildASTSchema' ;
12+ import { TypeInfo } from '../../utilities/TypeInfo' ;
1213
1314import { validate } from '../validate' ;
1415import type { ValidationContext } from '../ValidationContext' ;
@@ -57,6 +58,35 @@ describe('Validate: Supports full validation', () => {
5758 ] ) ;
5859 } ) ;
5960
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+
6090 it ( 'validates using a custom rule' , ( ) => {
6191 const schema = buildSchema ( `
6292 directive @custom(arg: String) on FIELD
0 commit comments