@smartive/graphql-magic 22.3.0-next.1 → 22.3.0

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.
@@ -8,14 +8,14 @@ jobs:
8
8
  docs:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
- - uses: actions/checkout@v4
11
+ - uses: actions/checkout@v6
12
12
  with:
13
13
  persist-credentials: false
14
14
 
15
15
  - name: Setup Node
16
- uses: actions/setup-node@v4
16
+ uses: actions/setup-node@v6
17
17
  with:
18
- node-version: '20'
18
+ node-version: '24'
19
19
  - name: Install and Build
20
20
  run: |
21
21
  cd docs
@@ -10,12 +10,12 @@ jobs:
10
10
  name: build and release
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
- - uses: actions/checkout@v4
13
+ - uses: actions/checkout@v6
14
14
  with:
15
15
  submodules: true
16
- - uses: actions/setup-node@v4
16
+ - uses: actions/setup-node@v6
17
17
  with:
18
- node-version: 20
18
+ node-version: 24
19
19
  - run: npm ci
20
20
  - run: npm run build
21
21
  - name: semantic release
@@ -15,9 +15,13 @@ jobs:
15
15
  matrix:
16
16
  node:
17
17
  - version: 22
18
+ - version: 24
18
19
  postgres:
19
- - version: 13
20
20
  - version: 14
21
+ - version: 15
22
+ - version: 16
23
+ - version: 17
24
+ - version: 18
21
25
  name: test and build package (node ${{ matrix.node.version }}, postgres ${{ matrix.postgres.version }})
22
26
  runs-on: ubuntu-latest
23
27
  container: node:${{ matrix.node.version }}-alpine
@@ -40,7 +44,7 @@ jobs:
40
44
 
41
45
  steps:
42
46
  - name: Checkout code
43
- uses: actions/checkout@v4
47
+ uses: actions/checkout@v6
44
48
  - name: Install dependencies
45
49
  run: npm ci
46
50
  - name: Lint
package/.nvmrc CHANGED
@@ -1 +1 @@
1
- 22
1
+ 24
package/CHANGELOG.md CHANGED
@@ -1,3 +1,4 @@
1
- ## 22.3.0-next.1 (2025-12-02)
1
+ ## 22.3.0 (2025-12-03)
2
2
 
3
- * feat: Generated fields ([4e53f60](https://github.com/smartive/graphql-magic/commit/4e53f60))
3
+ * feat: Add query debugging (#384) ([5288cb6](https://github.com/smartive/graphql-magic/commit/5288cb6)), closes [#384](https://github.com/smartive/graphql-magic/issues/384)
4
+ * chore(deps): update dependency del-cli to v7 (#354) ([3f466b5](https://github.com/smartive/graphql-magic/commit/3f466b5)), closes [#354](https://github.com/smartive/graphql-magic/issues/354)
package/dist/bin/gqm.cjs CHANGED
@@ -849,23 +849,32 @@ var MigrationGenerator = class {
849
849
  up,
850
850
  down
851
851
  );
852
- const rawExistingFields = model.fields.filter((field) => {
853
- if (!field.generateAs) {
854
- return false;
855
- }
852
+ const existingFields = model.fields.filter((field) => {
856
853
  const col = this.getColumn(model.name, field.kind === "relation" ? `${field.name}Id` : field.name);
857
854
  if (!col) {
858
855
  return false;
859
856
  }
860
- if (col.generation_expression !== field.generateAs) {
857
+ if (!field.nonNull && !col.is_nullable || field.nonNull && col.is_nullable) {
861
858
  return true;
862
859
  }
863
- return this.hasChanged(model, field);
860
+ if (!field.kind || field.kind === "primitive") {
861
+ if (field.type === "Int") {
862
+ if (col.data_type !== "integer") {
863
+ return true;
864
+ }
865
+ }
866
+ if (field.type === "Float") {
867
+ if (field.double) {
868
+ if (col.data_type !== "double precision") {
869
+ return true;
870
+ }
871
+ } else if (col.data_type !== "numeric") {
872
+ return true;
873
+ }
874
+ }
875
+ }
876
+ return false;
864
877
  });
865
- if (rawExistingFields.length) {
866
- this.updateFieldsRaw(model, rawExistingFields, up, down);
867
- }
868
- const existingFields = model.fields.filter((field) => !field.generateAs && this.hasChanged(model, field));
869
878
  this.updateFields(model, existingFields, up, down);
870
879
  }
871
880
  if (isUpdatableModel(model)) {
@@ -1008,9 +1017,6 @@ var MigrationGenerator = class {
1008
1017
  const postAlter = [];
1009
1018
  for (const field of fields2) {
1010
1019
  alter.push(() => this.column(field, { setNonNull: field.defaultValue !== void 0 }));
1011
- if (field.generateAs) {
1012
- continue;
1013
- }
1014
1020
  if (field.nonNull && field.defaultValue === void 0) {
1015
1021
  updates.push(() => this.writer.write(`${field.name}: 'TODO',`).newLine());
1016
1022
  postAlter.push(() => this.column(field, { alter: true, foreign: false }));
@@ -1034,56 +1040,12 @@ var MigrationGenerator = class {
1034
1040
  });
1035
1041
  down.push(() => {
1036
1042
  this.alterTable(model.name, () => {
1037
- for (const { kind, name: name2 } of fields2.toReversed()) {
1043
+ for (const { kind, name: name2 } of fields2) {
1038
1044
  this.dropColumn(kind === "relation" ? `${name2}Id` : name2);
1039
1045
  }
1040
1046
  });
1041
1047
  });
1042
1048
  }
1043
- updateFieldsRaw(model, fields2, up, down) {
1044
- if (!fields2.length) {
1045
- return;
1046
- }
1047
- up.push(() => {
1048
- this.alterTableRaw(model.name, () => {
1049
- for (const [index, field] of fields2.entries()) {
1050
- this.columnRaw(field, { alter: true }, index);
1051
- }
1052
- });
1053
- });
1054
- down.push(() => {
1055
- this.alterTableRaw(model.name, () => {
1056
- for (const [index, field] of fields2.entries()) {
1057
- this.columnRaw(field, { alter: true }, index);
1058
- }
1059
- });
1060
- });
1061
- if (isUpdatableModel(model)) {
1062
- const updatableFields = fields2.filter(isUpdatableField);
1063
- if (!updatableFields.length) {
1064
- return;
1065
- }
1066
- up.push(() => {
1067
- this.alterTable(`${model.name}Revision`, () => {
1068
- for (const [index, field] of updatableFields.entries()) {
1069
- this.columnRaw(field, { alter: true }, index);
1070
- }
1071
- });
1072
- });
1073
- down.push(() => {
1074
- this.alterTable(`${model.name}Revision`, () => {
1075
- for (const [index, field] of updatableFields.entries()) {
1076
- this.columnRaw(
1077
- field,
1078
- { alter: true },
1079
- index,
1080
- summonByName(this.columns[model.name], field.kind === "relation" ? `${field.name}Id` : field.name)
1081
- );
1082
- }
1083
- });
1084
- });
1085
- }
1086
- }
1087
1049
  updateFields(model, fields2, up, down) {
1088
1050
  if (!fields2.length) {
1089
1051
  return;
@@ -1204,11 +1166,6 @@ var MigrationGenerator = class {
1204
1166
  createTable(table, block) {
1205
1167
  return this.writer.write(`await knex.schema.createTable('${table}', (table) => `).inlineBlock(block).write(");").newLine().blankLine();
1206
1168
  }
1207
- alterTableRaw(table, block) {
1208
- this.writer.write(`await knex.raw('ALTER TABLE "${table}"`);
1209
- block();
1210
- this.writer.write(`');`).newLine().blankLine();
1211
- }
1212
1169
  alterTable(table, block) {
1213
1170
  return this.writer.write(`await knex.schema.alterTable('${table}', (table) => `).inlineBlock(block).write(");").newLine().blankLine();
1214
1171
  }
@@ -1230,107 +1187,25 @@ var MigrationGenerator = class {
1230
1187
  }
1231
1188
  return value2;
1232
1189
  }
1233
- columnRaw({ name: name2, ...field }, { setNonNull = true, alter = false } = {}, index, toColumn) {
1234
- const nonNull2 = () => {
1190
+ column({ name: name2, primary, list: list2, ...field }, { setUnique = true, setNonNull = true, alter = false, foreign = true, setDefault = true } = {}, toColumn) {
1191
+ const col = (what) => {
1192
+ if (what) {
1193
+ this.writer.write(what);
1194
+ }
1235
1195
  if (setNonNull) {
1236
1196
  if (toColumn) {
1237
1197
  if (toColumn.is_nullable) {
1238
- return false;
1239
- }
1240
- return true;
1241
- }
1242
- if (field.nonNull) {
1243
- return true;
1244
- }
1245
- return false;
1246
- }
1247
- };
1248
- const kind = field.kind;
1249
- if (field.generateAs) {
1250
- let type = "";
1251
- switch (kind) {
1252
- case void 0:
1253
- case "primitive":
1254
- switch (field.type) {
1255
- case "Float":
1256
- type = `decimal(${field.precision ?? "undefined"}, ${field.scale ?? "undefined"})`;
1257
- break;
1258
- default:
1259
- throw new Error(`Generated columns of kind ${kind} and type ${field.type} are not supported yet.`);
1260
- }
1261
- break;
1262
- default:
1263
- throw new Error(`Generated columns of kind ${kind} are not supported yet.`);
1264
- }
1265
- if (index) {
1266
- this.writer.write(`,`);
1267
- }
1268
- if (alter) {
1269
- this.writer.write(` ALTER COLUMN "${name2}" TYPE ${type}`);
1270
- if (setNonNull) {
1271
- if (nonNull2()) {
1272
- this.writer.write(`, ALTER COLUMN "${name2}" SET NOT NULL`);
1198
+ this.writer.write(`.nullable()`);
1273
1199
  } else {
1274
- this.writer.write(`, ALTER COLUMN "${name2}" DROP NOT NULL`);
1200
+ this.writer.write(".notNullable()");
1275
1201
  }
1276
- }
1277
- this.writer.write(`, ALTER COLUMN "${name2}" SET EXPRESSION AS (${field.generateAs})`);
1278
- } else {
1279
- this.writer.write(
1280
- `${alter ? "ALTER" : "ADD"} COLUMN "${name2}" ${type}${nonNull2() ? " not null" : ""} GENERATED ALWAYS AS (${field.generateAs}) STORED`
1281
- );
1282
- }
1283
- return;
1284
- }
1285
- throw new Error(`Only generated columns can be created with columnRaw`);
1286
- }
1287
- column({ name: name2, primary, list: list2, ...field }, { setUnique = true, setNonNull = true, alter = false, foreign = true, setDefault = true } = {}, toColumn) {
1288
- const nonNull2 = () => {
1289
- if (setNonNull) {
1290
- if (toColumn) {
1291
- if (toColumn.is_nullable) {
1292
- return false;
1202
+ } else {
1203
+ if (field.nonNull) {
1204
+ this.writer.write(`.notNullable()`);
1205
+ } else {
1206
+ this.writer.write(".nullable()");
1293
1207
  }
1294
- return true;
1295
1208
  }
1296
- if (field.nonNull) {
1297
- return true;
1298
- }
1299
- return false;
1300
- }
1301
- };
1302
- const kind = field.kind;
1303
- if (field.generateAs) {
1304
- let type = "";
1305
- switch (kind) {
1306
- case void 0:
1307
- case "primitive":
1308
- switch (field.type) {
1309
- case "Float":
1310
- type = `decimal(${field.precision ?? "undefined"}, ${field.scale ?? "undefined"})`;
1311
- break;
1312
- default:
1313
- throw new Error(`Generated columns of kind ${kind} and type ${field.type} are not supported yet.`);
1314
- }
1315
- break;
1316
- default:
1317
- throw new Error(`Generated columns of kind ${kind} are not supported yet.`);
1318
- }
1319
- this.writer.write(
1320
- `table.specificType('${name2}', '${type}${nonNull2() ? " not null" : ""} GENERATED ALWAYS AS (${field.generateAs}) STORED')`
1321
- );
1322
- if (alter) {
1323
- this.writer.write(".alter()");
1324
- }
1325
- this.writer.write(";").newLine();
1326
- return;
1327
- }
1328
- const col = (what) => {
1329
- if (what) {
1330
- this.writer.write(what);
1331
- }
1332
- if (setNonNull) {
1333
- this.writer.write(nonNull2() ? ".notNullable()" : ".nullable()");
1334
1209
  }
1335
1210
  if (setDefault && field.defaultValue !== void 0) {
1336
1211
  this.writer.write(`.defaultTo(${this.value(field.defaultValue)})`);
@@ -1345,6 +1220,7 @@ var MigrationGenerator = class {
1345
1220
  }
1346
1221
  this.writer.write(";").newLine();
1347
1222
  };
1223
+ const kind = field.kind;
1348
1224
  switch (kind) {
1349
1225
  case void 0:
1350
1226
  case "primitive":
@@ -1414,39 +1290,6 @@ var MigrationGenerator = class {
1414
1290
  getColumn(tableName, columnName) {
1415
1291
  return this.columns[tableName].find((col) => col.name === columnName);
1416
1292
  }
1417
- hasChanged(model, field) {
1418
- const col = this.getColumn(model.name, field.kind === "relation" ? `${field.name}Id` : field.name);
1419
- if (!col) {
1420
- return false;
1421
- }
1422
- if (field.generateAs) {
1423
- if (col.generation_expression !== field.generateAs) {
1424
- throw new Error(
1425
- `Column ${col.name} has specific type ${col.generation_expression} but expected ${field.generateAs}`
1426
- );
1427
- }
1428
- }
1429
- if (!field.nonNull && !col.is_nullable || field.nonNull && col.is_nullable) {
1430
- return true;
1431
- }
1432
- if (!field.kind || field.kind === "primitive") {
1433
- if (field.type === "Int") {
1434
- if (col.data_type !== "integer") {
1435
- return true;
1436
- }
1437
- }
1438
- if (field.type === "Float") {
1439
- if (field.double) {
1440
- if (col.data_type !== "double precision") {
1441
- return true;
1442
- }
1443
- } else if (col.data_type !== "numeric") {
1444
- return true;
1445
- }
1446
- }
1447
- }
1448
- return false;
1449
- }
1450
1293
  };
1451
1294
  var getMigrationDate = () => {
1452
1295
  const date = /* @__PURE__ */ new Date();
@@ -1213,23 +1213,32 @@ var MigrationGenerator = class {
1213
1213
  up,
1214
1214
  down
1215
1215
  );
1216
- const rawExistingFields = model.fields.filter((field) => {
1217
- if (!field.generateAs) {
1218
- return false;
1219
- }
1216
+ const existingFields = model.fields.filter((field) => {
1220
1217
  const col = this.getColumn(model.name, field.kind === "relation" ? `${field.name}Id` : field.name);
1221
1218
  if (!col) {
1222
1219
  return false;
1223
1220
  }
1224
- if (col.generation_expression !== field.generateAs) {
1221
+ if (!field.nonNull && !col.is_nullable || field.nonNull && col.is_nullable) {
1225
1222
  return true;
1226
1223
  }
1227
- return this.hasChanged(model, field);
1224
+ if (!field.kind || field.kind === "primitive") {
1225
+ if (field.type === "Int") {
1226
+ if (col.data_type !== "integer") {
1227
+ return true;
1228
+ }
1229
+ }
1230
+ if (field.type === "Float") {
1231
+ if (field.double) {
1232
+ if (col.data_type !== "double precision") {
1233
+ return true;
1234
+ }
1235
+ } else if (col.data_type !== "numeric") {
1236
+ return true;
1237
+ }
1238
+ }
1239
+ }
1240
+ return false;
1228
1241
  });
1229
- if (rawExistingFields.length) {
1230
- this.updateFieldsRaw(model, rawExistingFields, up, down);
1231
- }
1232
- const existingFields = model.fields.filter((field) => !field.generateAs && this.hasChanged(model, field));
1233
1242
  this.updateFields(model, existingFields, up, down);
1234
1243
  }
1235
1244
  if (isUpdatableModel(model)) {
@@ -1372,9 +1381,6 @@ var MigrationGenerator = class {
1372
1381
  const postAlter = [];
1373
1382
  for (const field of fields2) {
1374
1383
  alter.push(() => this.column(field, { setNonNull: field.defaultValue !== void 0 }));
1375
- if (field.generateAs) {
1376
- continue;
1377
- }
1378
1384
  if (field.nonNull && field.defaultValue === void 0) {
1379
1385
  updates.push(() => this.writer.write(`${field.name}: 'TODO',`).newLine());
1380
1386
  postAlter.push(() => this.column(field, { alter: true, foreign: false }));
@@ -1398,56 +1404,12 @@ var MigrationGenerator = class {
1398
1404
  });
1399
1405
  down.push(() => {
1400
1406
  this.alterTable(model.name, () => {
1401
- for (const { kind, name: name2 } of fields2.toReversed()) {
1407
+ for (const { kind, name: name2 } of fields2) {
1402
1408
  this.dropColumn(kind === "relation" ? `${name2}Id` : name2);
1403
1409
  }
1404
1410
  });
1405
1411
  });
1406
1412
  }
1407
- updateFieldsRaw(model, fields2, up, down) {
1408
- if (!fields2.length) {
1409
- return;
1410
- }
1411
- up.push(() => {
1412
- this.alterTableRaw(model.name, () => {
1413
- for (const [index, field] of fields2.entries()) {
1414
- this.columnRaw(field, { alter: true }, index);
1415
- }
1416
- });
1417
- });
1418
- down.push(() => {
1419
- this.alterTableRaw(model.name, () => {
1420
- for (const [index, field] of fields2.entries()) {
1421
- this.columnRaw(field, { alter: true }, index);
1422
- }
1423
- });
1424
- });
1425
- if (isUpdatableModel(model)) {
1426
- const updatableFields = fields2.filter(isUpdatableField);
1427
- if (!updatableFields.length) {
1428
- return;
1429
- }
1430
- up.push(() => {
1431
- this.alterTable(`${model.name}Revision`, () => {
1432
- for (const [index, field] of updatableFields.entries()) {
1433
- this.columnRaw(field, { alter: true }, index);
1434
- }
1435
- });
1436
- });
1437
- down.push(() => {
1438
- this.alterTable(`${model.name}Revision`, () => {
1439
- for (const [index, field] of updatableFields.entries()) {
1440
- this.columnRaw(
1441
- field,
1442
- { alter: true },
1443
- index,
1444
- summonByName(this.columns[model.name], field.kind === "relation" ? `${field.name}Id` : field.name)
1445
- );
1446
- }
1447
- });
1448
- });
1449
- }
1450
- }
1451
1413
  updateFields(model, fields2, up, down) {
1452
1414
  if (!fields2.length) {
1453
1415
  return;
@@ -1568,11 +1530,6 @@ var MigrationGenerator = class {
1568
1530
  createTable(table, block) {
1569
1531
  return this.writer.write(`await knex.schema.createTable('${table}', (table) => `).inlineBlock(block).write(");").newLine().blankLine();
1570
1532
  }
1571
- alterTableRaw(table, block) {
1572
- this.writer.write(`await knex.raw('ALTER TABLE "${table}"`);
1573
- block();
1574
- this.writer.write(`');`).newLine().blankLine();
1575
- }
1576
1533
  alterTable(table, block) {
1577
1534
  return this.writer.write(`await knex.schema.alterTable('${table}', (table) => `).inlineBlock(block).write(");").newLine().blankLine();
1578
1535
  }
@@ -1594,107 +1551,25 @@ var MigrationGenerator = class {
1594
1551
  }
1595
1552
  return value2;
1596
1553
  }
1597
- columnRaw({ name: name2, ...field }, { setNonNull = true, alter = false } = {}, index, toColumn) {
1598
- const nonNull2 = () => {
1554
+ column({ name: name2, primary, list: list2, ...field }, { setUnique = true, setNonNull = true, alter = false, foreign = true, setDefault = true } = {}, toColumn) {
1555
+ const col = (what) => {
1556
+ if (what) {
1557
+ this.writer.write(what);
1558
+ }
1599
1559
  if (setNonNull) {
1600
1560
  if (toColumn) {
1601
1561
  if (toColumn.is_nullable) {
1602
- return false;
1603
- }
1604
- return true;
1605
- }
1606
- if (field.nonNull) {
1607
- return true;
1608
- }
1609
- return false;
1610
- }
1611
- };
1612
- const kind = field.kind;
1613
- if (field.generateAs) {
1614
- let type = "";
1615
- switch (kind) {
1616
- case void 0:
1617
- case "primitive":
1618
- switch (field.type) {
1619
- case "Float":
1620
- type = `decimal(${field.precision ?? "undefined"}, ${field.scale ?? "undefined"})`;
1621
- break;
1622
- default:
1623
- throw new Error(`Generated columns of kind ${kind} and type ${field.type} are not supported yet.`);
1624
- }
1625
- break;
1626
- default:
1627
- throw new Error(`Generated columns of kind ${kind} are not supported yet.`);
1628
- }
1629
- if (index) {
1630
- this.writer.write(`,`);
1631
- }
1632
- if (alter) {
1633
- this.writer.write(` ALTER COLUMN "${name2}" TYPE ${type}`);
1634
- if (setNonNull) {
1635
- if (nonNull2()) {
1636
- this.writer.write(`, ALTER COLUMN "${name2}" SET NOT NULL`);
1562
+ this.writer.write(`.nullable()`);
1637
1563
  } else {
1638
- this.writer.write(`, ALTER COLUMN "${name2}" DROP NOT NULL`);
1564
+ this.writer.write(".notNullable()");
1639
1565
  }
1640
- }
1641
- this.writer.write(`, ALTER COLUMN "${name2}" SET EXPRESSION AS (${field.generateAs})`);
1642
- } else {
1643
- this.writer.write(
1644
- `${alter ? "ALTER" : "ADD"} COLUMN "${name2}" ${type}${nonNull2() ? " not null" : ""} GENERATED ALWAYS AS (${field.generateAs}) STORED`
1645
- );
1646
- }
1647
- return;
1648
- }
1649
- throw new Error(`Only generated columns can be created with columnRaw`);
1650
- }
1651
- column({ name: name2, primary, list: list2, ...field }, { setUnique = true, setNonNull = true, alter = false, foreign = true, setDefault = true } = {}, toColumn) {
1652
- const nonNull2 = () => {
1653
- if (setNonNull) {
1654
- if (toColumn) {
1655
- if (toColumn.is_nullable) {
1656
- return false;
1566
+ } else {
1567
+ if (field.nonNull) {
1568
+ this.writer.write(`.notNullable()`);
1569
+ } else {
1570
+ this.writer.write(".nullable()");
1657
1571
  }
1658
- return true;
1659
- }
1660
- if (field.nonNull) {
1661
- return true;
1662
1572
  }
1663
- return false;
1664
- }
1665
- };
1666
- const kind = field.kind;
1667
- if (field.generateAs) {
1668
- let type = "";
1669
- switch (kind) {
1670
- case void 0:
1671
- case "primitive":
1672
- switch (field.type) {
1673
- case "Float":
1674
- type = `decimal(${field.precision ?? "undefined"}, ${field.scale ?? "undefined"})`;
1675
- break;
1676
- default:
1677
- throw new Error(`Generated columns of kind ${kind} and type ${field.type} are not supported yet.`);
1678
- }
1679
- break;
1680
- default:
1681
- throw new Error(`Generated columns of kind ${kind} are not supported yet.`);
1682
- }
1683
- this.writer.write(
1684
- `table.specificType('${name2}', '${type}${nonNull2() ? " not null" : ""} GENERATED ALWAYS AS (${field.generateAs}) STORED')`
1685
- );
1686
- if (alter) {
1687
- this.writer.write(".alter()");
1688
- }
1689
- this.writer.write(";").newLine();
1690
- return;
1691
- }
1692
- const col = (what) => {
1693
- if (what) {
1694
- this.writer.write(what);
1695
- }
1696
- if (setNonNull) {
1697
- this.writer.write(nonNull2() ? ".notNullable()" : ".nullable()");
1698
1573
  }
1699
1574
  if (setDefault && field.defaultValue !== void 0) {
1700
1575
  this.writer.write(`.defaultTo(${this.value(field.defaultValue)})`);
@@ -1709,6 +1584,7 @@ var MigrationGenerator = class {
1709
1584
  }
1710
1585
  this.writer.write(";").newLine();
1711
1586
  };
1587
+ const kind = field.kind;
1712
1588
  switch (kind) {
1713
1589
  case void 0:
1714
1590
  case "primitive":
@@ -1778,39 +1654,6 @@ var MigrationGenerator = class {
1778
1654
  getColumn(tableName, columnName) {
1779
1655
  return this.columns[tableName].find((col) => col.name === columnName);
1780
1656
  }
1781
- hasChanged(model, field) {
1782
- const col = this.getColumn(model.name, field.kind === "relation" ? `${field.name}Id` : field.name);
1783
- if (!col) {
1784
- return false;
1785
- }
1786
- if (field.generateAs) {
1787
- if (col.generation_expression !== field.generateAs) {
1788
- throw new Error(
1789
- `Column ${col.name} has specific type ${col.generation_expression} but expected ${field.generateAs}`
1790
- );
1791
- }
1792
- }
1793
- if (!field.nonNull && !col.is_nullable || field.nonNull && col.is_nullable) {
1794
- return true;
1795
- }
1796
- if (!field.kind || field.kind === "primitive") {
1797
- if (field.type === "Int") {
1798
- if (col.data_type !== "integer") {
1799
- return true;
1800
- }
1801
- }
1802
- if (field.type === "Float") {
1803
- if (field.double) {
1804
- if (col.data_type !== "double precision") {
1805
- return true;
1806
- }
1807
- } else if (col.data_type !== "numeric") {
1808
- return true;
1809
- }
1810
- }
1811
- }
1812
- return false;
1813
- }
1814
1657
  };
1815
1658
  var getMigrationDate = () => {
1816
1659
  const date = /* @__PURE__ */ new Date();
@@ -2096,6 +1939,9 @@ var checkCanWrite = async (ctx, model, data, action) => {
2096
1939
  }
2097
1940
  const role = getRole(ctx);
2098
1941
  if (linked) {
1942
+ if (process.env.DEBUG_GRAPHQL_MAGIC === "true") {
1943
+ console.debug("QUERY", query.toString());
1944
+ }
2099
1945
  const canMutate = await query;
2100
1946
  if (!canMutate) {
2101
1947
  throw new PermissionError(role, action, `this ${model.name}`, "no linkable entities");
@@ -2766,6 +2612,9 @@ var resolve = async (ctx, id) => {
2766
2612
  if (!node.isList) {
2767
2613
  void query.limit(1);
2768
2614
  }
2615
+ if (process.env.DEBUG_GRAPHQL_MAGIC === "true") {
2616
+ console.debug("QUERY", query.toString());
2617
+ }
2769
2618
  const raw = await query;
2770
2619
  const res = hydrate(node, raw);
2771
2620
  await applySubQueries(node, res, verifiedPermissionStacks);
@@ -12,23 +12,19 @@ export declare class MigrationGenerator {
12
12
  generate(): Promise<string>;
13
13
  private renameFields;
14
14
  private createFields;
15
- private updateFieldsRaw;
16
15
  private updateFields;
17
16
  private createRevisionTable;
18
17
  private createRevisionFields;
19
18
  private createEnums;
20
19
  private migration;
21
20
  private createTable;
22
- private alterTableRaw;
23
21
  private alterTable;
24
22
  private dropColumn;
25
23
  private dropTable;
26
24
  private renameTable;
27
25
  private renameColumn;
28
26
  private value;
29
- private columnRaw;
30
27
  private column;
31
28
  private getColumn;
32
- private hasChanged;
33
29
  }
34
30
  export declare const getMigrationDate: () => string;