@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.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})` : ""} {