diff --git a/src/utilities/TypeInfo.ts b/src/utilities/TypeInfo.ts index 2fd4765c30..75a4eab9ff 100644 --- a/src/utilities/TypeInfo.ts +++ b/src/utilities/TypeInfo.ts @@ -3,7 +3,6 @@ import type { Maybe } from '../jsutils/Maybe.js'; import type { ASTNode, DocumentNode, - FieldNode, FragmentDefinitionNode, VariableDefinitionNode, } from '../language/ast.js'; @@ -64,7 +63,6 @@ export class TypeInfo { private _fragmentSignature: Maybe; private _fragmentArgument: Maybe; - private _getFieldDef: GetFieldDefFn; constructor( schema: GraphQLSchema, @@ -73,9 +71,6 @@ export class TypeInfo { * beginning somewhere other than documents. */ initialType?: Maybe, - - /** @deprecated will be removed in 17.0.0 */ - getFieldDefFn?: Maybe, fragmentSignatures?: Maybe< (fragmentName: string) => Maybe >, @@ -92,7 +87,6 @@ export class TypeInfo { this._fragmentSignaturesByName = fragmentSignatures ?? (() => null); this._fragmentSignature = null; this._fragmentArgument = null; - this._getFieldDef = getFieldDefFn ?? getFieldDef; if (initialType) { if (isInputType(initialType)) { this._inputTypeStack.push(initialType); @@ -185,7 +179,7 @@ export class TypeInfo { let fieldDef; let fieldType: unknown; if (parentType) { - fieldDef = this._getFieldDef(schema, parentType, node); + fieldDef = schema.getField(parentType, node.name.value); if (fieldDef) { fieldType = fieldDef.type; } @@ -348,20 +342,6 @@ export class TypeInfo { } } -type GetFieldDefFn = ( - schema: GraphQLSchema, - parentType: GraphQLCompositeType, - fieldNode: FieldNode, -) => Maybe>; - -function getFieldDef( - schema: GraphQLSchema, - parentType: GraphQLCompositeType, - fieldNode: FieldNode, -) { - return schema.getField(parentType, fieldNode.name.value); -} - function getFragmentSignatures( document: DocumentNode, ): Map { diff --git a/src/validation/ValidationContext.ts b/src/validation/ValidationContext.ts index 7f881fc369..7f7114c4ef 100644 --- a/src/validation/ValidationContext.ts +++ b/src/validation/ValidationContext.ts @@ -205,7 +205,6 @@ export class ValidationContext extends ASTValidationContext { const typeInfo = new TypeInfo( this._schema, undefined, - undefined, this._typeInfo.getFragmentSignatureByName(), ); const fragmentDefinition = 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