@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 +6 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1161,7 +1161,7 @@ function buildGraphQLMutation(input) {
|
|
|
1161
1161
|
const varDefs = Object.keys(finalVariables).map((k) => `$${k}: String!`).join(", ");
|
|
1162
1162
|
if (datas) {
|
|
1163
1163
|
const dataArray = Array.isArray(datas) ? datas : [datas];
|
|
1164
|
-
const datasArg = variables && variables.datas ? "$datas" : `[${dataArray.map((d) => `{ ${buildDataValue(d)} }`).join(" ")}]`;
|
|
1164
|
+
const datasArg = variables && variables.datas ? "$datas" : dataArray.length === 1 ? `{ ${buildDataValue(dataArray[0])} }` : `[${dataArray.map((d) => `{ ${buildDataValue(d)} }`).join(" ")}]`;
|
|
1165
1165
|
if (!variables || !variables.datas) finalVariables.datas = dataArray;
|
|
1166
1166
|
const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
|
|
1167
1167
|
${operationName}(${variableName ?? "datas"}: ${datasArg}) {
|
|
@@ -1173,7 +1173,8 @@ function buildGraphQLMutation(input) {
|
|
|
1173
1173
|
}
|
|
1174
1174
|
if (_set) {
|
|
1175
1175
|
if (!where) throw new Error("update mutation requires where condition");
|
|
1176
|
-
const
|
|
1176
|
+
const setArgArray = Array.isArray(_set) ? _set : [_set];
|
|
1177
|
+
const setArg = variables && variables._set ? "$_set" : setArgArray.length === 1 ? `{ ${buildDataValue(setArgArray[0])} }` : `[${setArgArray.map((d) => `{ ${buildDataValue(d)} }`).join(" ")}]`;
|
|
1177
1178
|
if (!variables || !variables._set) finalVariables._set = _set;
|
|
1178
1179
|
const whereArg = buildWhere(where);
|
|
1179
1180
|
const query2 = `mutation ${operationName}${varDefs ? `(${varDefs})` : ""} {
|
|
@@ -1849,9 +1850,6 @@ var CCRequest = class {
|
|
|
1849
1850
|
// ===== 请求逻辑 =====
|
|
1850
1851
|
async request(query2, variables) {
|
|
1851
1852
|
let queryStr = typeof query2 === "string" ? query2 : print(query2);
|
|
1852
|
-
if (!/refreshToken/i.test(queryStr)) {
|
|
1853
|
-
await this.ensureTokenValid();
|
|
1854
|
-
}
|
|
1855
1853
|
const { deviceId, deviceName } = await this.deviceInfoPromise;
|
|
1856
1854
|
let headersWithDevice = Object.fromEntries(
|
|
1857
1855
|
Object.entries({
|
|
@@ -1875,6 +1873,9 @@ var CCRequest = class {
|
|
|
1875
1873
|
}
|
|
1876
1874
|
}
|
|
1877
1875
|
try {
|
|
1876
|
+
if (!/refreshToken/i.test(queryStr)) {
|
|
1877
|
+
await this.ensureTokenValid();
|
|
1878
|
+
}
|
|
1878
1879
|
const res = await this.client.rawRequest(
|
|
1879
1880
|
queryStr,
|
|
1880
1881
|
variables,
|