/** 压缩字符串 */ export function compress(gql: string): string { if (!gql) return ''; // 不处理有内联字符串和注释的查询 if (gql.includes('"') || gql.includes('#')) return gql; return ( gql // replace multiple whitespace with a single .replaceAll(/\s+/gm, ' ') // remove all whitespace between everything except for word and word boundaries .replaceAll(/(?!^)((\b)\s+(\B)|(\B)\s+(\b)|(\B)\s+(\B))(?!$)/gm, '') ); }