import { isTemplateStringsArray } from './template-string.js'; import { GqlTemplate, type GqlTemplateValue } from './template.js'; /** 从字面量创建 GQL 模板 */ export function gql(value: string | number | undefined | boolean | bigint): GqlTemplate; /** 从插值字符串创建 GQL 模板 */ export function gql(query: TemplateStringsArray, ...args: GqlTemplateValue[]): GqlTemplate; /** 创建 GQL 模板 */ export function gql( query: TemplateStringsArray | string | number | undefined | boolean | bigint, ...args: GqlTemplateValue[] ): GqlTemplate { if (isTemplateStringsArray(query)) { return GqlTemplate(query, args); } if (args.length !== 0) throw new Error('Invalid additional arguments'); if (query == null) return GqlTemplate({ raw: [''] }, []); if (typeof query == 'function' || typeof query == 'object') throw new Error('Invalid type of value'); return GqlTemplate({ raw: [String(query)] }, []); } export { GqlFragment } from './fragment.js'; export { GqlTemplate } from './template.js'; export { GqlEnum } from './enum.js'; export { GqlVariable } from './variable.js'; export type { GqlTemplateValue } from './template.js';