@ctil/gql 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3997,7 +3997,7 @@ function buildGraphQLMutation(input) {
3997
3997
  const varDefs = Object.keys(finalVariables).map((k) => `$${k}: String!`).join(", ");
3998
3998
  if (datas) {
3999
3999
  const dataArray = Array.isArray(datas) ? datas : [datas];
4000
- const datasArg = variables && variables.datas ? "$datas" : `[${dataArray.map((d) => `{ ${buildDataValue(d)} }`).join(" ")}]`;
4000
+ const datasArg = variables && variables.datas ? "$datas" : dataArray.length === 1 ? `{ ${buildDataValue(dataArray[0])} }` : `[${dataArray.map((d) => `{ ${buildDataValue(d)} }`).join(" ")}]`;
4001
4001
  if (!variables || !variables.datas) finalVariables.datas = dataArray;
4002
4002
  const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
4003
4003
  ${operationName}(${variableName ?? "datas"}: ${datasArg}) {
@@ -4009,7 +4009,8 @@ function buildGraphQLMutation(input) {
4009
4009
  }
4010
4010
  if (_set) {
4011
4011
  if (!where) throw new Error("update mutation requires where condition");
4012
- const setArg = variables && variables._set ? "$_set" : Array.isArray(_set) ? `[${_set.map((s) => `{ ${buildDataValue(s)} }`).join(" ")}]` : `{ ${buildDataValue(_set)} }`;
4012
+ const setArgArray = Array.isArray(_set) ? _set : [_set];
4013
+ const setArg = variables && variables._set ? "$_set" : setArgArray.length === 1 ? `{ ${buildDataValue(setArgArray[0])} }` : `[${setArgArray.map((d) => `{ ${buildDataValue(d)} }`).join(" ")}]`;
4013
4014
  if (!variables || !variables._set) finalVariables._set = _set;
4014
4015
  const whereArg = buildWhere(where);
4015
4016
  const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
@@ -4685,9 +4686,6 @@ var CCRequest = class {
4685
4686
  // ===== 请求逻辑 =====
4686
4687
  async request(query2, variables) {
4687
4688
  let queryStr = typeof query2 === "string" ? query2 : print(query2);
4688
- if (!/refreshToken/i.test(queryStr)) {
4689
- await this.ensureTokenValid();
4690
- }
4691
4689
  const { deviceId, deviceName } = await this.deviceInfoPromise;
4692
4690
  let headersWithDevice = Object.fromEntries(
4693
4691
  Object.entries({
@@ -4711,6 +4709,9 @@ var CCRequest = class {
4711
4709
  }
4712
4710
  }
4713
4711
  try {
4712
+ if (!/refreshToken/i.test(queryStr)) {
4713
+ await this.ensureTokenValid();
4714
+ }
4714
4715
  const res = await this.client.rawRequest(
4715
4716
  queryStr,
4716
4717
  variables,