@ctil/gql 1.1.4 → 1.1.5

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.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 setArg = variables && variables._set ? "$_set" : Array.isArray(_set) ? `[${_set.map((s) => `{ ${buildDataValue(s)} }`).join(" ")}]` : `{ ${buildDataValue(_set)} }`;
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})` : ""} {