Skip to content

Commit

Permalink
remove deprecated custom typeInfo arg for validate() (#4187)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR authored Sep 9, 2024
1 parent 1bfa115 commit c7d1cf4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
30 changes: 0 additions & 30 deletions src/validation/__tests__/validation-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions src/validation/validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ export function validate(
documentAST: DocumentNode,
rules: ReadonlyArray<ValidationRule> = specifiedRules,
options?: { maxErrors?: number },

/** @deprecated will be removed in 17.0.0 */
typeInfo: TypeInfo = new TypeInfo(schema),
): ReadonlyArray<GraphQLError> {
const maxErrors = options?.maxErrors ?? 100;

Expand All @@ -55,6 +52,7 @@ export function validate(
'Too many validation errors, error limit reached. Validation aborted.',
);
const errors: Array<GraphQLError> = [];
const typeInfo = new TypeInfo(schema);
const context = new ValidationContext(
schema,
documentAST,
Expand Down

0 comments on commit c7d1cf4

Please sign in to comment.