import type { Node } from 'web-tree-sitter'; import type { InputValueDefinitionNode } from './input_value_definition.js'; const TYPE = 'input_fields_definition' as const; // ================================================================ // ================================================================ // // InputFieldsDefinitionNode // // GraphQL input fields definition node // // ================================================================ // ================================================================ /** * Represents a input fields definition in the GraphQL AST. * * Children: * {@link InputValueDefinitionNode} * */ export interface InputFieldsDefinitionNode extends Node { type: typeof TYPE; } // ================================================================ // ================================================================ // // Type Guard // // ================================================================ // ================================================================ /** * Type guard to check if a node is a {@link InputFieldsDefinitionNode}. * * @param node - The node to check * @returns True if the node is a {@link InputFieldsDefinitionNode} * * @example * ```typescript * if (isInputFieldsDefinitionNode(node)) { * // TypeScript now knows node is InputFieldsDefinitionNode * console.log(node.type); // 'input_fields_definition' * } * ``` */ export function isInputFieldsDefinitionNode(node: unknown): node is InputFieldsDefinitionNode { return (node as any)?.type === TYPE; } // ================================================================ // ================================================================ // // Constructor // // ================================================================ // ================================================================ /** * Creates a new {@link InputFieldsDefinitionNode} with the specified properties. * * @param props - The node properties * @param props.inputvaluedefinition - {@link InputValueDefinitionNode} * @returns A new {@link InputFieldsDefinitionNode} * * @example * ```typescript * const node = InputFieldsDefinitionNode({ * // properties... * }); * ``` */ export function InputFieldsDefinitionNode(props: Omit): InputFieldsDefinitionNode { return { type: TYPE, ...props }; }