| /** @category Validation Rules */ |
| import type { ASTVisitor } from '../../language/visitor'; |
| import type { ValidationContext } from '../ValidationContext'; |
| /** |
| * Scalar leafs |
| * |
| * A GraphQL document is valid only if all leaf fields (fields without |
| * sub selections) are of scalar or enum types. |
| * @param context - The validation context used while checking the document. |
| * @returns A visitor that reports validation errors for this rule. |
| * @example |
| * ```ts |
| * import { buildSchema, parse, validate } from 'graphql'; |
| * import { ScalarLeafsRule } from 'graphql/validation'; |
| * |
| * const schema = buildSchema(` |
| * type Query { |
| * name: String |
| * } |
| * `); |
| * |
| * const invalidDocument = parse(` |
| * { name { length } } |
| * `); |
| * const invalidErrors = validate(schema, invalidDocument, [ScalarLeafsRule]); |
| * |
| * invalidErrors.length; // => 1 |
| * |
| * const validDocument = parse(` |
| * { name } |
| * `); |
| * const validErrors = validate(schema, validDocument, [ScalarLeafsRule]); |
| * |
| * validErrors; // => [] |
| * ``` |
| */ |
| export declare function ScalarLeafsRule(context: ValidationContext): ASTVisitor; |