import { GQL_VARIABLE, isGqlEnum, GQL_ENUM } from './symbols.js'; import { formatType, type GqlType } from './type.js'; /** 表示一个 GQL 变量 */ // eslint-disable-next-line @typescript-eslint/no-explicit-any export interface GqlVariable { /** 变量的 GQL 类型 */ [GQL_VARIABLE]: GqlType; /** 变量值 */ value: V; } /** 创建一个 GQL 变量 */ export function GqlVariable(value: V, type: T): GqlVariable { if (isGqlEnum(value)) { // GQL Enum 直接转字符串 value = value[GQL_ENUM] as unknown as V; } return { [GQL_VARIABLE]: formatType(type, false), value, }; }