@ctil/gql 1.1.3 → 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 +3 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -245,8 +245,8 @@ declare function buildGraphQLQueryAggregate(input: QueryAggregateInput): {
|
|
|
245
245
|
interface MutationInput {
|
|
246
246
|
operationName: string;
|
|
247
247
|
fields: FieldInput[];
|
|
248
|
-
datas?: Record<string, any>[];
|
|
249
|
-
_set?: Record<string, any>[];
|
|
248
|
+
datas?: Record<string, any> | Record<string, any>[];
|
|
249
|
+
_set?: Record<string, any> | Record<string, any>[];
|
|
250
250
|
where?: WhereInput;
|
|
251
251
|
variables?: Record<string, any>;
|
|
252
252
|
variableName?: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -245,8 +245,8 @@ declare function buildGraphQLQueryAggregate(input: QueryAggregateInput): {
|
|
|
245
245
|
interface MutationInput {
|
|
246
246
|
operationName: string;
|
|
247
247
|
fields: FieldInput[];
|
|
248
|
-
datas?: Record<string, any>[];
|
|
249
|
-
_set?: Record<string, any>[];
|
|
248
|
+
datas?: Record<string, any> | Record<string, any>[];
|
|
249
|
+
_set?: Record<string, any> | Record<string, any>[];
|
|
250
250
|
where?: WhereInput;
|
|
251
251
|
variables?: Record<string, any>;
|
|
252
252
|
variableName?: string;
|
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})` : ""} {
|