UNPKG

graphql

Version:

A Query Language and Runtime which can target any service.

30 lines (29 loc) 1 kB
/** @category Validation Rules */ import type { ASTVisitor } from "../../language/visitor.js"; import type { SDLValidationContext } from "../ValidationContext.js"; /** * Unique field definition names * * A GraphQL complex type is only valid if all its fields are uniquely named. * @param context - The validation context used while checking the document. * @returns A visitor that reports validation errors for this rule. * @example * ```ts * import { buildSchema } from 'graphql'; * import { UniqueFieldDefinitionNamesRule } from 'graphql/validation'; * * const invalidSDL = ` * type Query { name: String name: String } * `; * * UniqueFieldDefinitionNamesRule.name; // => 'UniqueFieldDefinitionNamesRule' * buildSchema(invalidSDL); // throws an error * * const validSDL = ` * type Query { name: String other: String } * `; * * buildSchema(validSDL); // does not throw * ``` */ export declare function UniqueFieldDefinitionNamesRule(context: SDLValidationContext): ASTVisitor;