import type { Node } from 'web-tree-sitter'; import type { NamedTypeNode } from './named_type.js'; import type { OperationTypeNode } from './operation_type.js'; const TYPE = 'root_operation_type_definition' as const; // ================================================================ // ================================================================ // // RootOperationTypeDefinitionNode // // GraphQL root operation type definition node // // ================================================================ // ================================================================ /** * Represents a root operation type definition in the GraphQL AST. * * Children: * {@link NamedTypeNode}, {@link OperationTypeNode} * */ export interface RootOperationTypeDefinitionNode extends Node { type: typeof TYPE; } // ================================================================ // ================================================================ // // Type Guard // // ================================================================ // ================================================================ /** * Type guard to check if a node is a {@link RootOperationTypeDefinitionNode}. * * @param node - The node to check * @returns True if the node is a {@link RootOperationTypeDefinitionNode} * * @example * ```typescript * if (isRootOperationTypeDefinitionNode(node)) { * // TypeScript now knows node is RootOperationTypeDefinitionNode * console.log(node.type); // 'root_operation_type_definition' * } * ``` */ export function isRootOperationTypeDefinitionNode(node: unknown): node is RootOperationTypeDefinitionNode { return (node as any)?.type === TYPE; } // ================================================================ // ================================================================ // // Constructor // // ================================================================ // ================================================================ /** * Creates a new {@link RootOperationTypeDefinitionNode} with the specified properties. * * @param props - The node properties * @param props.namedtype - {@link NamedTypeNode} * @param props.operationtype - {@link OperationTypeNode} * @returns A new {@link RootOperationTypeDefinitionNode} * * @example * ```typescript * const node = RootOperationTypeDefinitionNode({ * // properties... * }); * ``` */ export function RootOperationTypeDefinitionNode(props: Omit): RootOperationTypeDefinitionNode { return { type: TYPE, ...props }; }