From c7d1cf4536b31810fa8d996ff15a6a6483ff3d35 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Mon, 9 Sep 2024 18:47:58 +0300 Subject: [PATCH] remove deprecated custom typeInfo arg for validate() (#4187) --- src/validation/__tests__/validation-test.ts | 30 --------------------- src/validation/validate.ts | 4 +-- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/validation/__tests__/validation-test.ts b/src/validation/__tests__/validation-test.ts index 19cb3b178a..13de153c39 100644 --- a/src/validation/__tests__/validation-test.ts +++ b/src/validation/__tests__/validation-test.ts @@ -9,7 +9,6 @@ import type { DirectiveNode } from '../../language/ast.js'; import { parse } from '../../language/parser.js'; import { buildSchema } from '../../utilities/buildASTSchema.js'; -import { TypeInfo } from '../../utilities/TypeInfo.js'; import { validate } from '../validate.js'; import type { ValidationContext } from '../ValidationContext.js'; @@ -53,35 +52,6 @@ describe('Validate: Supports full validation', () => { ]); }); - it('Deprecated: validates using a custom TypeInfo', () => { - // This TypeInfo will never return a valid field. - const typeInfo = new TypeInfo(testSchema, null, () => null); - - const doc = parse(` - query { - human { - pets { - ... on Cat { - meowsVolume - } - ... on Dog { - barkVolume - } - } - } - } - `); - - const errors = validate(testSchema, doc, undefined, undefined, typeInfo); - const errorMessages = errors.map((error) => error.message); - - expect(errorMessages).to.deep.equal([ - 'Cannot query field "human" on type "QueryRoot". Did you mean "human"?', - 'Cannot query field "meowsVolume" on type "Cat". Did you mean "meowsVolume"?', - 'Cannot query field "barkVolume" on type "Dog". Did you mean "barkVolume"?', - ]); - }); - it('validates using a custom rule', () => { const schema = buildSchema(` directive @custom(arg: String) on FIELD diff --git a/src/validation/validate.ts b/src/validation/validate.ts index 93da49be78..e380d167d9 100644 --- a/src/validation/validate.ts +++ b/src/validation/validate.ts @@ -42,9 +42,6 @@ export function validate( documentAST: DocumentNode, rules: ReadonlyArray = specifiedRules, options?: { maxErrors?: number }, - - /** @deprecated will be removed in 17.0.0 */ - typeInfo: TypeInfo = new TypeInfo(schema), ): ReadonlyArray { const maxErrors = options?.maxErrors ?? 100; @@ -55,6 +52,7 @@ export function validate( 'Too many validation errors, error limit reached. Validation aborted.', ); const errors: Array = []; + const typeInfo = new TypeInfo(schema); const context = new ValidationContext( schema, documentAST,