@vantreeseba/drizzle-graphql 6.0.0 → 7.0.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.
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  desc,
19
19
  eq,
20
20
  extractExtendedColumnType as extractExtendedColumnType2,
21
- getColumns,
21
+ getColumns as getColumns2,
22
22
  getTableAsAliasSQL,
23
23
  gt,
24
24
  gte,
@@ -38,17 +38,17 @@ import {
38
38
  One as One2,
39
39
  or,
40
40
  relationsFilterToSQL,
41
- sql
41
+ sql as sql2
42
42
  } from "drizzle-orm";
43
43
  import {
44
44
  GraphQLBoolean as GraphQLBoolean2,
45
45
  GraphQLEnumType as GraphQLEnumType2,
46
- GraphQLError as GraphQLError3,
47
- GraphQLFloat as GraphQLFloat2,
48
- GraphQLInputObjectType as GraphQLInputObjectType2,
49
- GraphQLInt as GraphQLInt2,
50
- GraphQLList as GraphQLList2,
51
- GraphQLNonNull as GraphQLNonNull2,
46
+ GraphQLError as GraphQLError4,
47
+ GraphQLFloat as GraphQLFloat3,
48
+ GraphQLInputObjectType as GraphQLInputObjectType3,
49
+ GraphQLInt as GraphQLInt3,
50
+ GraphQLList as GraphQLList3,
51
+ GraphQLNonNull as GraphQLNonNull3,
52
52
  GraphQLObjectType as GraphQLObjectType2,
53
53
  GraphQLString as GraphQLString2
54
54
  } from "graphql";
@@ -602,6 +602,131 @@ var remapFromGraphQLArrayInput = (queryInput, table) => {
602
602
  return queryInput;
603
603
  };
604
604
 
605
+ // src/util/builders/field-updates.ts
606
+ import { getColumns, sql } from "drizzle-orm";
607
+ import {
608
+ GraphQLError as GraphQLError3,
609
+ GraphQLFloat as GraphQLFloat2,
610
+ GraphQLInputObjectType as GraphQLInputObjectType2,
611
+ GraphQLInt as GraphQLInt2,
612
+ GraphQLList as GraphQLList2,
613
+ GraphQLNonNull as GraphQLNonNull2
614
+ } from "graphql";
615
+ var NUMERIC_SCALARS = /* @__PURE__ */ new Set([
616
+ GraphQLInt2,
617
+ GraphQLFloat2,
618
+ GraphQLBigIntString,
619
+ GraphQLDecimalString
620
+ ]);
621
+ var NON_LIST_ARRAY_COLUMNS = /* @__PURE__ */ new Set(["PgVector", "PgGeometry", "PgBytea"]);
622
+ var kindCache = /* @__PURE__ */ new WeakMap();
623
+ var fieldUpdateKind = (column, columnName, tableName) => {
624
+ const cached = kindCache.get(column);
625
+ if (cached) {
626
+ return cached;
627
+ }
628
+ let kind = "none";
629
+ if (!getColumnScalarOverride(column, true)) {
630
+ const { type } = drizzleColumnToGraphQLType(column, columnName, tableName, true, false, true);
631
+ if (NUMERIC_SCALARS.has(type)) {
632
+ kind = "numeric";
633
+ } else if (type instanceof GraphQLList2 && !NON_LIST_ARRAY_COLUMNS.has(column.columnType)) {
634
+ kind = "list";
635
+ }
636
+ }
637
+ kindCache.set(column, kind);
638
+ return kind;
639
+ };
640
+ var inputCache = /* @__PURE__ */ new Map();
641
+ var namedFieldUpdateInput = (name, fields, description) => {
642
+ const cached = inputCache.get(name);
643
+ if (cached) {
644
+ return cached;
645
+ }
646
+ const input = new GraphQLInputObjectType2({ name, description, fields: fields() });
647
+ inputCache.set(name, input);
648
+ return input;
649
+ };
650
+ var fieldUpdateInputType = (column, columnName, tableName) => {
651
+ const kind = fieldUpdateKind(column, columnName, tableName);
652
+ if (kind === "none") {
653
+ return void 0;
654
+ }
655
+ const { type } = drizzleColumnToGraphQLType(column, columnName, tableName, true, false, true);
656
+ if (kind === "numeric") {
657
+ const scalar = type;
658
+ return namedFieldUpdateInput(
659
+ `${scalar.name}FieldUpdate`,
660
+ () => ({
661
+ set: { type: scalar, description: "Replace the current value with this one" },
662
+ increment: { type: scalar, description: "Add this to the current value (SQL `column + value`)" },
663
+ decrement: { type: scalar, description: "Subtract this from the current value (SQL `column - value`)" },
664
+ multiply: { type: scalar, description: "Multiply the current value by this (SQL `column * value`)" },
665
+ divide: {
666
+ type: scalar,
667
+ description: "Divide the current value by this (SQL `column / value`), rounding as the database does"
668
+ }
669
+ }),
670
+ `An update to a ${scalar.name} column: exactly one of these operations`
671
+ );
672
+ }
673
+ const list = type;
674
+ const element = list.ofType;
675
+ const elementName = element instanceof GraphQLNonNull2 ? String(element.ofType) : String(element);
676
+ return namedFieldUpdateInput(
677
+ `${elementName}ListFieldUpdate`,
678
+ () => ({
679
+ set: { type: list, description: "Replace the current array with this one" },
680
+ push: { type: list, description: "Append these elements to the current array" }
681
+ }),
682
+ `An update to a ${elementName} array column: exactly one of these operations`
683
+ );
684
+ };
685
+ var OPERATIONS = ["set", "increment", "decrement", "multiply", "divide", "push"];
686
+ var singleOperation = (value, columnName) => {
687
+ const given = OPERATIONS.filter((operation) => value[operation] !== void 0);
688
+ if (given.length === 1) {
689
+ return [given[0], value[given[0]]];
690
+ }
691
+ throw new GraphQLError3(
692
+ given.length ? `Field '${columnName}' takes exactly one update operation, but ${given.length} were given (${given.join(", ")}).` : `Field '${columnName}' was given no update operation. Pass exactly one of ${OPERATIONS.join(", ")}.`
693
+ );
694
+ };
695
+ var splitFieldUpdateOperations = (values, table, tableName) => {
696
+ const cols = getColumns(table);
697
+ const columns = {};
698
+ const expressions = {};
699
+ for (const [columnName, value] of Object.entries(values)) {
700
+ const column = cols[columnName];
701
+ if (!column || value === null || value === void 0) {
702
+ columns[columnName] = value;
703
+ continue;
704
+ }
705
+ const isOperations = typeof value === "object" && !Array.isArray(value) && !(value instanceof Date);
706
+ if (!isOperations || fieldUpdateKind(column, columnName, tableName) === "none") {
707
+ columns[columnName] = value;
708
+ continue;
709
+ }
710
+ const [operation, operand] = singleOperation(value, columnName);
711
+ if (operation === "set") {
712
+ columns[columnName] = operand;
713
+ continue;
714
+ }
715
+ const param = sql.param(remapFromGraphQLCore(operand, column, columnName), column);
716
+ expressions[columnName] = operation === "increment" ? sql`${column} + ${param}` : operation === "decrement" ? sql`${column} - ${param}` : operation === "multiply" ? sql`${column} * ${param}` : operation === "divide" ? sql`${column} / ${param}` : (
717
+ // `push`: array concatenation, which is the only dialect-specific operation
718
+ // here — and arrays are a PostgreSQL column type to begin with.
719
+ sql`${column} || ${param}`
720
+ );
721
+ }
722
+ return { columns, expressions };
723
+ };
724
+ var remapUpdateInput = (values, table, tableName) => {
725
+ const { columns, expressions } = splitFieldUpdateOperations(values, table, tableName);
726
+ const remapped = remapFromGraphQLSingleInput(columns, table);
727
+ return Object.keys(expressions).length ? { ...remapped, ...expressions } : remapped;
728
+ };
729
+
605
730
  // src/util/builders/common.ts
606
731
  var rqbCrashTypes = ["SQLiteBigInt", "SQLiteBlobJson", "SQLiteBlobBuffer"];
607
732
  var resolveTypeName = (name, typeNameMapper) => {
@@ -664,9 +789,9 @@ var extractRelationJoinColumns = (relEntry, parentTable, targetTable) => {
664
789
  }
665
790
  const sourceCol = sourceColumns[0];
666
791
  const targetCol = targetColumns[0];
667
- const parentCols = getColumns(parentTable);
792
+ const parentCols = getColumns2(parentTable);
668
793
  const localColPropName = Object.entries(parentCols).find(([, c]) => c === sourceCol)?.[0];
669
- const targetCols = getColumns(targetTable);
794
+ const targetCols = getColumns2(targetTable);
670
795
  const foreignColPropName = Object.entries(targetCols).find(([, c]) => c === targetCol)?.[0];
671
796
  if (!localColPropName || !foreignColPropName) {
672
797
  return void 0;
@@ -748,7 +873,7 @@ var collectRootMutationKeys = (selectionSet, fragments, variables, known, keys,
748
873
  }
749
874
  return true;
750
875
  };
751
- var abortedBatchError = () => new GraphQLError3(
876
+ var abortedBatchError = () => new GraphQLError4(
752
877
  "Drizzle-GraphQL Error: Mutation was not executed because an earlier mutation in the same request failed and the shared transaction was rolled back."
753
878
  );
754
879
  var openSharedTx = (db, context, txCtx, stateKey, expected) => {
@@ -806,7 +931,7 @@ var openSharedTx = (db, context, txCtx, stateKey, expected) => {
806
931
  }
807
932
  timer = setTimeout(() => {
808
933
  state.abort(
809
- new GraphQLError3(
934
+ new GraphQLError4(
810
935
  `Drizzle-GraphQL Error: Shared mutation transaction timed out after ${txCtx.timeoutMs}ms waiting for the remaining mutation fields; rolling back.`
811
936
  )
812
937
  );
@@ -888,14 +1013,14 @@ var runMutation = async (db, context, info, txCtx, body) => {
888
1013
  return runOnSharedTx(state, body);
889
1014
  };
890
1015
  var batchedPaginatedRelationQuery = async (db, targetTable, foreignCol, whereCondition, orderByArg, limit, offset, pkNames, orderCtx) => {
891
- const cols = getColumns(targetTable);
1016
+ const cols = getColumns2(targetTable);
892
1017
  const orderExprs = [
893
1018
  ...orderByArg ? extractOrderBy(targetTable, orderByArg, orderCtx) : [],
894
1019
  ...primaryKeyOrderExprs(targetTable, pkNames)
895
1020
  ];
896
- const orderClause = orderExprs.length ? sql` order by ${sql.join(orderExprs, sql`, `)}` : sql``;
1021
+ const orderClause = orderExprs.length ? sql2` order by ${sql2.join(orderExprs, sql2`, `)}` : sql2``;
897
1022
  const RN = "__drizzle_graphql_rn";
898
- const rowNumber = sql`row_number() over (partition by ${foreignCol}${orderClause})`.as(RN);
1023
+ const rowNumber = sql2`row_number() over (partition by ${foreignCol}${orderClause})`.as(RN);
899
1024
  const sub = db.select({ ...cols, [RN]: rowNumber }).from(targetTable).where(whereCondition).as("__paginated");
900
1025
  const lower = offset ?? 0;
901
1026
  const windowConds = [gt(sub[RN], lower)];
@@ -908,7 +1033,7 @@ var batchedPaginatedRelationQuery = async (db, targetTable, foreignCol, whereCon
908
1033
  }
909
1034
  return rows;
910
1035
  };
911
- var createRelationResolverFactory = (db, tables, filterCtx) => ({ tableName, relationName, relEntry, isOne }) => {
1036
+ var createRelationResolverFactory = (db, tables, nullOrdering, filterCtx) => ({ tableName, relationName, relEntry, isOne }) => {
912
1037
  const parentTable = tables[tableName];
913
1038
  const targetTableName = relEntry.targetTableName;
914
1039
  const targetTable = tables[targetTableName];
@@ -921,7 +1046,7 @@ var createRelationResolverFactory = (db, tables, filterCtx) => ({ tableName, rel
921
1046
  }
922
1047
  const { localColPropName, foreignCol, foreignColPropName } = joinCols;
923
1048
  const targetPkNames = relEntry.targetPkNames ?? [];
924
- return async (parent, args, context) => {
1049
+ return async (parent, args, context, info) => {
925
1050
  if (parent[relationName] !== void 0) {
926
1051
  return parent[relationName];
927
1052
  }
@@ -929,21 +1054,65 @@ var createRelationResolverFactory = (db, tables, filterCtx) => ({ tableName, rel
929
1054
  if (localValue == null) {
930
1055
  return isOne ? null : [];
931
1056
  }
932
- const { where: whereArg, orderBy: orderByArg, limit, offset } = args ?? {};
1057
+ const { where: whereArg, orderBy: orderByArg, limit, offset, after } = args ?? {};
1058
+ const distinct = (args ?? {}).distinct?.length ? (args ?? {}).distinct : void 0;
1059
+ const cursorSelected = !isOne && !!info && selectsCursorField(info, targetTable);
1060
+ let cursorEntries;
1061
+ if (!isOne && (after != null || cursorSelected)) {
1062
+ if (after != null && distinct) {
1063
+ throw new GraphQLError4("'after' cannot be combined with 'distinct'.");
1064
+ }
1065
+ if (orderByHasRelationEntry(orderByArg)) {
1066
+ if (after != null) {
1067
+ throw new GraphQLError4(
1068
+ "'after' cannot be combined with an orderBy that orders through a relation \u2014 a related row's value cannot be encoded into a cursor."
1069
+ );
1070
+ }
1071
+ } else if (!targetPkNames.length) {
1072
+ if (after != null) {
1073
+ throw new GraphQLError4(
1074
+ `Table ${targetTableName} has no primary key, so cursor pagination cannot be used on it.`
1075
+ );
1076
+ }
1077
+ } else {
1078
+ cursorEntries = cursorOrderingEntries(orderByArg, targetPkNames);
1079
+ }
1080
+ }
1081
+ const cursorValues = after != null && cursorEntries ? decodeCursor(after, cursorEntries) : void 0;
933
1082
  const argsKey = JSON.stringify({
934
1083
  where: whereArg ?? null,
935
1084
  orderBy: orderByArg ?? null,
936
1085
  limit: limit ?? null,
937
- offset: offset ?? null
1086
+ offset: offset ?? null,
1087
+ after: after ?? null,
1088
+ distinct: distinct ?? null,
1089
+ cursor: cursorEntries ? 1 : 0
938
1090
  });
939
1091
  const loaderKey = `${tableName}::${relationName}::${argsKey}`;
940
1092
  const loader = getOrCreateLoader(context, loaderKey, async (parentIds) => {
941
1093
  const executor = resolveExecutor(db, context);
942
1094
  const uniqueIds = [...new Set(parentIds)];
943
- const whereCondition = and(
1095
+ let whereCondition = and(
944
1096
  inArray(foreignCol, uniqueIds),
945
- whereArg ? extractFilters(targetTable, targetTableName, whereArg, relationFilterCtx(filterCtx, targetTableName)) : void 0
1097
+ whereArg ? extractFilters(targetTable, targetTableName, whereArg, relationFilterCtx(filterCtx, targetTableName)) : void 0,
1098
+ cursorValues ? buildCursorCondition(targetTable, cursorEntries, cursorValues, nullOrdering) : void 0
946
1099
  );
1100
+ if (distinct) {
1101
+ const keys = await selectDistinctKeys({
1102
+ db: executor,
1103
+ table: targetTable,
1104
+ tableName: targetTableName,
1105
+ distinct,
1106
+ pkNames: targetPkNames,
1107
+ where: whereCondition,
1108
+ orderBy: orderByArg,
1109
+ partitionBy: [foreignCol]
1110
+ });
1111
+ if (!keys.length) {
1112
+ return parentIds.map(() => isOne ? null : []);
1113
+ }
1114
+ whereCondition = and(whereCondition, primaryKeyRestriction(targetTable, targetPkNames, keys));
1115
+ }
947
1116
  let rows;
948
1117
  if (limit != null || offset != null) {
949
1118
  rows = await batchedPaginatedRelationQuery(
@@ -959,11 +1128,15 @@ var createRelationResolverFactory = (db, tables, filterCtx) => ({ tableName, rel
959
1128
  );
960
1129
  } else {
961
1130
  let q = executor.select().from(targetTable).where(whereCondition);
962
- if (orderByArg) {
963
- q = q.orderBy(...extractOrderBy(targetTable, orderByArg, relationFilterCtx(filterCtx, targetTableName)));
1131
+ const orderExprs = cursorEntries ? cursorOrderExprs(targetTable, cursorEntries) : orderByArg ? extractOrderBy(targetTable, orderByArg, relationFilterCtx(filterCtx, targetTableName)) : [];
1132
+ if (orderExprs.length) {
1133
+ q = q.orderBy(...orderExprs);
964
1134
  }
965
1135
  rows = await q;
966
1136
  }
1137
+ if (cursorEntries) {
1138
+ attachRowCursors(rows, cursorEntries);
1139
+ }
967
1140
  if (isOne) {
968
1141
  const byKey = new Map(rows.map((row) => [String(row[foreignColPropName]), row]));
969
1142
  remapToGraphQLArrayOutput(rows, targetTableName, targetTable);
@@ -989,7 +1162,7 @@ var columnDocs = (docs, column, tableName, columnName) => {
989
1162
  };
990
1163
  var inputFieldDocs = (docs, column, tableName, columnName, fieldType) => {
991
1164
  const resolved = columnDocs(docs, column, tableName, columnName);
992
- if (resolved.deprecationReason !== void 0 && fieldType instanceof GraphQLNonNull2) {
1165
+ if (resolved.deprecationReason !== void 0 && fieldType instanceof GraphQLNonNull3) {
993
1166
  const { deprecationReason: _dropped, ...rest } = resolved;
994
1167
  return rest;
995
1168
  }
@@ -1010,7 +1183,7 @@ var relationJoinColumns = (tree, table, selectionCtx) => {
1010
1183
  if (!relations) {
1011
1184
  return [];
1012
1185
  }
1013
- const tableColumns = getColumns(table);
1186
+ const tableColumns = getColumns2(table);
1014
1187
  const needed = [];
1015
1188
  for (const fieldData of Object.values(tree)) {
1016
1189
  if (tableColumns[fieldData.name]) {
@@ -1029,7 +1202,7 @@ var relationJoinColumns = (tree, table, selectionCtx) => {
1029
1202
  return needed;
1030
1203
  };
1031
1204
  var extractSelectedColumnsFromTree = (tree, table, selectionCtx) => {
1032
- const tableColumns = getColumns(table);
1205
+ const tableColumns = getColumns2(table);
1033
1206
  const treeEntries = Object.entries(tree);
1034
1207
  const selectedColumns = [];
1035
1208
  for (const [_fieldName, fieldData] of treeEntries) {
@@ -1049,7 +1222,7 @@ var extractSelectedColumnsFromTree = (tree, table, selectionCtx) => {
1049
1222
  return Object.fromEntries(selectedColumns);
1050
1223
  };
1051
1224
  var extractSelectedColumnsFromTreeSQLFormat = (tree, table, selectionCtx) => {
1052
- const tableColumns = getColumns(table);
1225
+ const tableColumns = getColumns2(table);
1053
1226
  const treeEntries = Object.entries(tree);
1054
1227
  const selectedColumns = [];
1055
1228
  for (const [_fieldName, fieldData] of treeEntries) {
@@ -1082,11 +1255,11 @@ var orderNulls = new GraphQLEnumType2({
1082
1255
  }
1083
1256
  }
1084
1257
  });
1085
- var innerOrder = new GraphQLInputObjectType2({
1258
+ var innerOrder = new GraphQLInputObjectType3({
1086
1259
  name: "InnerOrder",
1087
1260
  fields: {
1088
1261
  direction: {
1089
- type: new GraphQLNonNull2(
1262
+ type: new GraphQLNonNull3(
1090
1263
  new GraphQLEnumType2({
1091
1264
  name: "OrderDirection",
1092
1265
  description: "Order by direction",
@@ -1104,7 +1277,7 @@ var innerOrder = new GraphQLInputObjectType2({
1104
1277
  )
1105
1278
  },
1106
1279
  priority: {
1107
- type: new GraphQLNonNull2(GraphQLInt2),
1280
+ type: new GraphQLNonNull3(GraphQLInt3),
1108
1281
  description: "Priority of current field"
1109
1282
  },
1110
1283
  nulls: {
@@ -1130,9 +1303,9 @@ var resolveGenericFilterDescriptor = (column, columnGraphQLType) => {
1130
1303
  if (columnGraphQLType.type === GraphQLJSON) {
1131
1304
  return { name: "JSON", kind: "json" };
1132
1305
  }
1133
- if (columnGraphQLType.type instanceof GraphQLList2) {
1306
+ if (columnGraphQLType.type instanceof GraphQLList3) {
1134
1307
  let element = columnGraphQLType.type.ofType;
1135
- if (element instanceof GraphQLNonNull2) {
1308
+ if (element instanceof GraphQLNonNull3) {
1136
1309
  element = element.ofType;
1137
1310
  }
1138
1311
  return { name: `${element.name}Array`, kind: "array" };
@@ -1156,10 +1329,10 @@ var resolveGenericFilterDescriptor = (column, columnGraphQLType) => {
1156
1329
  if (ct === "PgTimestamp" || ct === "PgTimestampString" || ct === "PgDate") {
1157
1330
  return { name: "DateTime", kind: "scalar" };
1158
1331
  }
1159
- if (columnGraphQLType.type === GraphQLInt2) {
1332
+ if (columnGraphQLType.type === GraphQLInt3) {
1160
1333
  return { name: "Int", kind: "scalar" };
1161
1334
  }
1162
- if (columnGraphQLType.type === GraphQLFloat2) {
1335
+ if (columnGraphQLType.type === GraphQLFloat3) {
1163
1336
  return { name: "Float", kind: "scalar" };
1164
1337
  }
1165
1338
  return { name: "String", kind: "scalar" };
@@ -1183,10 +1356,10 @@ var IN_ARRAY_DESCRIPTION = "Matches any one of these values (SQL `IN`)";
1183
1356
  var NOT_IN_ARRAY_DESCRIPTION = "Matches none of these values (SQL `NOT IN`)";
1184
1357
  var arrayFilterFields = (colType, colArr) => {
1185
1358
  let element = colType.ofType;
1186
- if (element instanceof GraphQLNonNull2) {
1359
+ if (element instanceof GraphQLNonNull3) {
1187
1360
  element = element.ofType;
1188
1361
  }
1189
- const elementList = new GraphQLList2(new GraphQLNonNull2(element));
1362
+ const elementList = new GraphQLList3(new GraphQLNonNull3(element));
1190
1363
  return {
1191
1364
  eq: { type: colType, description: "The whole array equals this array" },
1192
1365
  ne: { type: colType, description: "The whole array differs from this array" },
@@ -1203,8 +1376,8 @@ var arrayFilterFields = (colType, colArr) => {
1203
1376
  var FILTERS_WITHOUT_STRING_OPS = /* @__PURE__ */ new Set(["Id", "Int", "Float", "BigInt", "Decimal"]);
1204
1377
  var BUILTIN_FILTER_SCALARS = /* @__PURE__ */ new Set([
1205
1378
  GraphQLString2,
1206
- GraphQLInt2,
1207
- GraphQLFloat2,
1379
+ GraphQLInt3,
1380
+ GraphQLFloat3,
1208
1381
  GraphQLBoolean2,
1209
1382
  GraphQLBigIntString,
1210
1383
  GraphQLDecimalString,
@@ -1231,7 +1404,7 @@ var generateColumnFilterValues = (column, tableName, columnName, cacheCtx) => {
1231
1404
  return cached;
1232
1405
  }
1233
1406
  const colType = columnGraphQLType.type;
1234
- const colArr = new GraphQLList2(new GraphQLNonNull2(colType));
1407
+ const colArr = new GraphQLList3(new GraphQLNonNull3(colType));
1235
1408
  const customOverrideFilter = inputOverride !== void 0 && !BUILTIN_FILTER_SCALARS.has(inputOverride);
1236
1409
  const underlying = extractExtendedColumnType2(column);
1237
1410
  const omitStringOps = customOverrideFilter ? underlying.type !== "string" || underlying.constraint === "numeric" : FILTERS_WITHOUT_STRING_OPS.has(genericName);
@@ -1277,16 +1450,16 @@ var generateColumnFilterValues = (column, tableName, columnName, cacheCtx) => {
1277
1450
  isNull: { type: GraphQLBoolean2, description: "When true, matches rows where the column is NULL" },
1278
1451
  isNotNull: { type: GraphQLBoolean2, description: "When true, matches rows where the column is not NULL" }
1279
1452
  };
1280
- const mainType = new GraphQLInputObjectType2({
1453
+ const mainType = new GraphQLInputObjectType3({
1281
1454
  name: `${genericName}Filter`,
1282
1455
  fields: () => ({
1283
1456
  ...baseFields,
1284
1457
  OR: {
1285
- type: new GraphQLList2(new GraphQLNonNull2(mainType)),
1458
+ type: new GraphQLList3(new GraphQLNonNull3(mainType)),
1286
1459
  description: "At least one branch matches; ANDed with any sibling operators"
1287
1460
  },
1288
1461
  AND: {
1289
- type: new GraphQLList2(new GraphQLNonNull2(mainType)),
1462
+ type: new GraphQLList3(new GraphQLNonNull3(mainType)),
1290
1463
  description: "Every branch matches"
1291
1464
  },
1292
1465
  NOT: {
@@ -1305,7 +1478,7 @@ var generateTableOrderCached = (table) => {
1305
1478
  }
1306
1479
  let remapped = {};
1307
1480
  try {
1308
- const columns = getColumns(table);
1481
+ const columns = getColumns2(table);
1309
1482
  const columnEntries = Object.entries(columns);
1310
1483
  remapped = Object.fromEntries(
1311
1484
  columnEntries.map(([columnName, _columnDescription]) => [columnName, { type: innerOrder }])
@@ -1319,7 +1492,7 @@ var generateTableFilterValuesCached = (table, tableName, cacheCtx) => {
1319
1492
  if (cacheCtx.filterFieldCache.has(table)) {
1320
1493
  return cacheCtx.filterFieldCache.get(table);
1321
1494
  }
1322
- const columns = getColumns(table);
1495
+ const columns = getColumns2(table);
1323
1496
  const columnEntries = Object.entries(columns);
1324
1497
  const remapped = Object.fromEntries(
1325
1498
  columnEntries.map(([columnName, column]) => [
@@ -1340,7 +1513,7 @@ var generateTableSelectTypeFieldsCached = (table, tableName, cacheCtx) => {
1340
1513
  if (cacheCtx.selectFieldCache.has(table)) {
1341
1514
  return cacheCtx.selectFieldCache.get(table);
1342
1515
  }
1343
- const columns = getColumns(table);
1516
+ const columns = getColumns2(table);
1344
1517
  const columnEntries = Object.entries(columns);
1345
1518
  const remapped = Object.fromEntries(
1346
1519
  columnEntries.map(([columnName, column]) => [
@@ -1395,7 +1568,7 @@ var generateTableOrderTypeCached = (table, tableName, typeNameMapper, cacheCtx,
1395
1568
  if (cacheCtx.orderTypeCache.has(table)) {
1396
1569
  return cacheCtx.orderTypeCache.get(table);
1397
1570
  }
1398
- const order = new GraphQLInputObjectType2({
1571
+ const order = new GraphQLInputObjectType3({
1399
1572
  name: `${resolveTypeName(tableName, typeNameMapper)}OrderBy`,
1400
1573
  fields: () => {
1401
1574
  const orderColumns = generateTableOrderCached(table);
@@ -1413,7 +1586,7 @@ var generateListRelationFilterCached = (targetTable, targetTableName, cacheCtx,
1413
1586
  if (cached) {
1414
1587
  return cached;
1415
1588
  }
1416
- const listFilter = new GraphQLInputObjectType2({
1589
+ const listFilter = new GraphQLInputObjectType3({
1417
1590
  name: `${resolveTypeName(targetTableName, typeNameMapper)}ListRelationFilter`,
1418
1591
  fields: () => {
1419
1592
  const targetFilters = generateTableFilterTypeCached(
@@ -1483,16 +1656,16 @@ var generateTableFilterTypeCached = (table, tableName, cacheCtx, typeNameMapper,
1483
1656
  ...generateRelationFilterFields(tableName, cacheCtx, typeNameMapper, filterColumns, relationMap, tables)
1484
1657
  };
1485
1658
  };
1486
- const filters = new GraphQLInputObjectType2({
1659
+ const filters = new GraphQLInputObjectType3({
1487
1660
  name: `${resolveTypeName(tableName, typeNameMapper)}Filters`,
1488
1661
  fields: () => ({
1489
1662
  ...buildFields(),
1490
1663
  OR: {
1491
- type: new GraphQLList2(new GraphQLNonNull2(filters)),
1664
+ type: new GraphQLList3(new GraphQLNonNull3(filters)),
1492
1665
  description: "At least one branch matches; ANDed with any sibling fields"
1493
1666
  },
1494
1667
  AND: {
1495
- type: new GraphQLList2(new GraphQLNonNull2(filters)),
1668
+ type: new GraphQLList3(new GraphQLNonNull3(filters)),
1496
1669
  description: "Every branch matches"
1497
1670
  },
1498
1671
  NOT: {
@@ -1600,7 +1773,7 @@ var generateSelectFields = (tables, tableName, relationMap, fromTableName, fromR
1600
1773
  rawRelationFields.push([
1601
1774
  relationName,
1602
1775
  {
1603
- type: isRequired ? new GraphQLNonNull2(relType) : relType,
1776
+ type: isRequired ? new GraphQLNonNull3(relType) : relType,
1604
1777
  args: {
1605
1778
  where: { type: relSelectData.filters }
1606
1779
  },
@@ -1610,15 +1783,21 @@ var generateSelectFields = (tables, tableName, relationMap, fromTableName, fromR
1610
1783
  ]);
1611
1784
  continue;
1612
1785
  }
1786
+ const targetDistinctEnum = cacheCtx.features.distinct ? generateDistinctEnum(tables[targetTableName], resolveTypeName(targetTableName, typeNameMapper)) : void 0;
1613
1787
  rawRelationFields.push([
1614
1788
  relationName,
1615
1789
  {
1616
- type: new GraphQLNonNull2(new GraphQLList2(new GraphQLNonNull2(relType))),
1790
+ type: new GraphQLNonNull3(new GraphQLList3(new GraphQLNonNull3(relType))),
1617
1791
  args: {
1618
1792
  where: { type: relSelectData.filters },
1619
1793
  orderBy: { type: relSelectData.order },
1620
- offset: { type: GraphQLInt2 },
1621
- limit: { type: GraphQLInt2 }
1794
+ offset: { type: GraphQLInt3 },
1795
+ limit: { type: GraphQLInt3 },
1796
+ after: {
1797
+ type: GraphQLString2,
1798
+ description: "Keyset pagination: only return related rows strictly after this cursor (a row's `cursor` field from a previous page of this relation, under the same orderBy)."
1799
+ },
1800
+ ...targetDistinctEnum ? { distinct: { type: new GraphQLList3(new GraphQLNonNull3(targetDistinctEnum)) } } : {}
1622
1801
  },
1623
1802
  resolve,
1624
1803
  ...relationDocs,
@@ -1636,7 +1815,7 @@ var generateSelectFields = (tables, tableName, relationMap, fromTableName, fromR
1636
1815
  rawRelationFields.push([
1637
1816
  aggregateFieldName,
1638
1817
  {
1639
- type: new GraphQLNonNull2(relationAggregate.type),
1818
+ type: new GraphQLNonNull3(relationAggregate.type),
1640
1819
  args: {
1641
1820
  where: { type: relSelectData.filters }
1642
1821
  },
@@ -1688,7 +1867,7 @@ var generateTableTypes = (tableName, tables, relationMap, withReturning, relatio
1688
1867
  relationAggregateFactory
1689
1868
  );
1690
1869
  const table = tables[tableName];
1691
- const columns = getColumns(table);
1870
+ const columns = getColumns2(table);
1692
1871
  const columnEntries = Object.entries(columns);
1693
1872
  const relaxedColumns = nestedWrites?.relaxedColumns(tableName);
1694
1873
  const insertFields = Object.fromEntries(
@@ -1710,18 +1889,17 @@ var generateTableTypes = (tableName, tables, relationMap, withReturning, relatio
1710
1889
  const updateFields = Object.fromEntries(
1711
1890
  columnEntries.map(([columnName, column]) => {
1712
1891
  const converted = drizzleColumnToGraphQLType(column, columnName, tableName, true, false, true);
1713
- return [
1714
- columnName,
1715
- { ...converted, ...inputFieldDocs(cacheCtx.docs, column, tableName, columnName, converted.type) }
1716
- ];
1892
+ const operations = cacheCtx.features.fieldUpdateOperations ? fieldUpdateInputType(column, columnName, tableName) : void 0;
1893
+ const field = operations ? { ...converted, type: operations } : converted;
1894
+ return [columnName, { ...field, ...inputFieldDocs(cacheCtx.docs, column, tableName, columnName, field.type) }];
1717
1895
  })
1718
1896
  );
1719
1897
  const typeName = resolveTypeName(tableName, typeNameMapper);
1720
- const insertInput = new GraphQLInputObjectType2({
1898
+ const insertInput = new GraphQLInputObjectType3({
1721
1899
  name: `${capitalize(insertPrefix)}${typeName}Input`,
1722
1900
  fields: nestedWrites ? () => ({ ...insertFields, ...nestedWrites.createFields(tableName, typeName) }) : insertFields
1723
1901
  });
1724
- const updateInput = new GraphQLInputObjectType2({
1902
+ const updateInput = new GraphQLInputObjectType3({
1725
1903
  name: `${capitalize(updatePrefix)}${typeName}Input`,
1726
1904
  fields: nestedWrites ? () => ({ ...updateFields, ...nestedWrites.updateFields(tableName, typeName) }) : updateFields
1727
1905
  });
@@ -1730,10 +1908,10 @@ var generateTableTypes = (tableName, tables, relationMap, withReturning, relatio
1730
1908
  description: cacheCtx.docs.describeTable?.(tableName),
1731
1909
  fields: { ...tableFields, ...relationFields }
1732
1910
  });
1733
- const selectArrOutput = new GraphQLNonNull2(new GraphQLList2(new GraphQLNonNull2(selectSingleOutput)));
1911
+ const selectArrOutput = new GraphQLNonNull3(new GraphQLList3(new GraphQLNonNull3(selectSingleOutput)));
1734
1912
  const arrTableItemOutput = withReturning ? (
1735
1913
  // ? new GraphQLNonNull(new GraphQLList(new GraphQLNonNull(singleTableItemOutput!)))
1736
- new GraphQLNonNull2(new GraphQLList2(new GraphQLNonNull2(selectSingleOutput)))
1914
+ new GraphQLNonNull3(new GraphQLList3(new GraphQLNonNull3(selectSingleOutput)))
1737
1915
  ) : void 0;
1738
1916
  const inputs = {
1739
1917
  insertInput,
@@ -1758,7 +1936,7 @@ var generateTableTypes = (tableName, tables, relationMap, withReturning, relatio
1758
1936
  };
1759
1937
  var orderByEntries = (orderArgs) => Object.entries(orderArgs).sort((a, b) => (b[1]?.priority ?? 0) - (a[1]?.priority ?? 0)).filter(([, config]) => config).map(([column, config]) => {
1760
1938
  if (typeof config === "object" && config.direction === void 0) {
1761
- throw new GraphQLError3(`ORDER BY ${column}: ordering through a relation is not supported in this query`);
1939
+ throw new GraphQLError4(`ORDER BY ${column}: ordering through a relation is not supported in this query`);
1762
1940
  }
1763
1941
  return [column, config.direction, config.nulls ?? void 0];
1764
1942
  });
@@ -1769,16 +1947,16 @@ var orderExpressions = (expr, direction, nulls, dialectColumn) => {
1769
1947
  }
1770
1948
  const isMySql = (dialectColumn.columnType ?? "").startsWith("MySql");
1771
1949
  if (isMySql) {
1772
- const nullsKey = nulls === "first" ? desc(sql`(${expr} is null)`) : asc(sql`(${expr} is null)`);
1950
+ const nullsKey = nulls === "first" ? desc(sql2`(${expr} is null)`) : asc(sql2`(${expr} is null)`);
1773
1951
  return [nullsKey, directed];
1774
1952
  }
1775
- return [nulls === "first" ? sql`${directed} nulls first` : sql`${directed} nulls last`];
1953
+ return [nulls === "first" ? sql2`${directed} nulls first` : sql2`${directed} nulls last`];
1776
1954
  };
1777
1955
  var extendRelationOrderChain = (parentTable, relationName, relEntry, ctx, chain) => {
1778
1956
  const targetTable = ctx.tables[relEntry.targetTableName];
1779
1957
  const relation = relEntry.relation ?? relEntry;
1780
1958
  if (!targetTable || !is3(relation, One2) || !isFilterableRelation(relation)) {
1781
- throw new GraphQLError3(`ORDER BY ${relationName}: Relation cannot be used for ordering`);
1959
+ throw new GraphQLError4(`ORDER BY ${relationName}: Relation cannot be used for ordering`);
1782
1960
  }
1783
1961
  ctx.aliases ??= { n: 0 };
1784
1962
  const aliasedTarget = aliasedTable(targetTable, `dgql_ord_${ctx.aliases.n++}`);
@@ -1795,7 +1973,7 @@ var extendRelationOrderChain = (parentTable, relationName, relEntry, ctx, chain)
1795
1973
  };
1796
1974
  };
1797
1975
  var collectOrderEntries = (table, tableKey, orderArgs, ctx, chain, out) => {
1798
- const columns = getColumns(table);
1976
+ const columns = getColumns2(table);
1799
1977
  const relations = ctx?.relationMap[tableKey];
1800
1978
  for (const [key, config] of Object.entries(orderArgs)) {
1801
1979
  if (config === null || config === void 0) {
@@ -1804,7 +1982,7 @@ var collectOrderEntries = (table, tableKey, orderArgs, ctx, chain, out) => {
1804
1982
  const column = columns[key];
1805
1983
  if (column) {
1806
1984
  out.push({
1807
- expression: chain ? sql`(select ${column} from ${sql.join(chain.fromParts, sql`, `)} where ${and(...chain.conditions)})` : column,
1985
+ expression: chain ? sql2`(select ${column} from ${sql2.join(chain.fromParts, sql2`, `)} where ${and(...chain.conditions)})` : column,
1808
1986
  column,
1809
1987
  direction: config.direction,
1810
1988
  nulls: config.nulls ?? void 0,
@@ -1814,7 +1992,7 @@ var collectOrderEntries = (table, tableKey, orderArgs, ctx, chain, out) => {
1814
1992
  }
1815
1993
  const relEntry = relations?.[key];
1816
1994
  if (!relEntry || !ctx) {
1817
- throw new GraphQLError3(`ORDER BY ${key}: Unknown column or relation`);
1995
+ throw new GraphQLError4(`ORDER BY ${key}: Unknown column or relation`);
1818
1996
  }
1819
1997
  const nextChain = extendRelationOrderChain(chain?.table ?? table, key, relEntry, ctx, chain);
1820
1998
  collectOrderEntries(nextChain.table, relEntry.targetTableName, config, ctx, nextChain, out);
@@ -1837,21 +2015,21 @@ var safeLikeOps = {
1837
2015
  };
1838
2016
  var safeLikeCondition = (column, pattern, insensitive) => {
1839
2017
  if (!insensitive) {
1840
- return sql`${column} like ${pattern} escape ${LIKE_ESCAPE_CHAR}`;
2018
+ return sql2`${column} like ${pattern} escape ${LIKE_ESCAPE_CHAR}`;
1841
2019
  }
1842
2020
  const isPg = (column.columnType ?? "").startsWith("Pg");
1843
- return isPg ? sql`${column} ilike ${pattern} escape ${LIKE_ESCAPE_CHAR}` : sql`lower(${column}) like ${pattern.toLowerCase()} escape ${LIKE_ESCAPE_CHAR}`;
2021
+ return isPg ? sql2`${column} ilike ${pattern} escape ${LIKE_ESCAPE_CHAR}` : sql2`lower(${column}) like ${pattern.toLowerCase()} escape ${LIKE_ESCAPE_CHAR}`;
1844
2022
  };
1845
2023
  var isJsonColumn2 = (column) => (column.columnType ?? "").includes("Json");
1846
2024
  var jsonContains = (column, columnName, value) => {
1847
2025
  const serialized = JSON.stringify(value);
1848
2026
  switch (columnDialect(column)) {
1849
2027
  case "pg":
1850
- return column.columnType === "PgJson" ? sql`${column}::jsonb @> ${serialized}::jsonb` : sql`${column} @> ${serialized}::jsonb`;
2028
+ return column.columnType === "PgJson" ? sql2`${column}::jsonb @> ${serialized}::jsonb` : sql2`${column} @> ${serialized}::jsonb`;
1851
2029
  case "mysql":
1852
- return sql`json_contains(${column}, ${serialized})`;
2030
+ return sql2`json_contains(${column}, ${serialized})`;
1853
2031
  default:
1854
- throw new GraphQLError3(`WHERE ${columnName}: Operator 'contains' is not supported for this dialect!`);
2032
+ throw new GraphQLError4(`WHERE ${columnName}: Operator 'contains' is not supported for this dialect!`);
1855
2033
  }
1856
2034
  };
1857
2035
  var extractFiltersColumn = (column, columnName, operators) => {
@@ -1882,7 +2060,7 @@ var extractFiltersColumn = (column, columnName, operators) => {
1882
2060
  variants.push(safeLikeCondition(column, buildPattern(operatorValue), insensitive));
1883
2061
  } else if (operatorName in arrayValueOps) {
1884
2062
  if (!operatorValue.length) {
1885
- throw new GraphQLError3(`WHERE ${columnName}: Unable to use operator ${operatorName} with an empty array!`);
2063
+ throw new GraphQLError4(`WHERE ${columnName}: Unable to use operator ${operatorName} with an empty array!`);
1886
2064
  }
1887
2065
  const arrayValue = operatorValue.map((val) => remapFromGraphQLCore(val, column, columnName));
1888
2066
  variants.push(arrayValueOps[operatorName](column, arrayValue));
@@ -1890,15 +2068,15 @@ var extractFiltersColumn = (column, columnName, operators) => {
1890
2068
  variants.push(arrayContains(column, [operatorValue]));
1891
2069
  } else if (operatorName in arrayMembershipOps) {
1892
2070
  if (!operatorValue.length) {
1893
- throw new GraphQLError3(`WHERE ${columnName}: Unable to use operator ${operatorName} with an empty array!`);
2071
+ throw new GraphQLError4(`WHERE ${columnName}: Unable to use operator ${operatorName} with an empty array!`);
1894
2072
  }
1895
2073
  variants.push(arrayMembershipOps[operatorName](column, operatorValue));
1896
2074
  } else if (operatorName === "isEmpty") {
1897
- variants.push(sql`cardinality(${column}) = 0`);
2075
+ variants.push(sql2`cardinality(${column}) = 0`);
1898
2076
  } else if (operatorName in nullableOps) {
1899
2077
  variants.push(nullableOps[operatorName](column));
1900
2078
  } else {
1901
- throw new GraphQLError3(`WHERE ${columnName}: Unknown operator: ${operatorName}`);
2079
+ throw new GraphQLError4(`WHERE ${columnName}: Unknown operator: ${operatorName}`);
1902
2080
  }
1903
2081
  }
1904
2082
  if (AND?.length) {
@@ -1934,23 +2112,23 @@ var buildRelationJoinCondition = (parentTable, relation, aliasedTarget, relation
1934
2112
  const sourceColumns = relation.sourceColumns;
1935
2113
  const targetColumns = relation.targetColumns;
1936
2114
  if (!sourceColumns?.length || sourceColumns.length !== targetColumns?.length) {
1937
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2115
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
1938
2116
  }
1939
- const parentColumns = Object.values(getColumns(parentTable));
1940
- const targetColumnsByName = Object.values(getColumns(aliasedTarget));
2117
+ const parentColumns = Object.values(getColumns2(parentTable));
2118
+ const targetColumnsByName = Object.values(getColumns2(aliasedTarget));
1941
2119
  const conditions = [];
1942
2120
  for (let i = 0; i < sourceColumns.length; i++) {
1943
2121
  const localColumn = parentColumns.find((c) => c.name === sourceColumns[i].name);
1944
2122
  const foreignColumn = targetColumnsByName.find((c) => c.name === targetColumns[i].name);
1945
2123
  if (!localColumn || !foreignColumn) {
1946
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2124
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
1947
2125
  }
1948
2126
  conditions.push(eq(localColumn, foreignColumn));
1949
2127
  }
1950
2128
  return conditions.length > 1 ? and(...conditions) : conditions[0];
1951
2129
  };
1952
2130
  var resolveJunctionColumn = (aliasedThrough, junctionRef, relationName) => {
1953
- const throughColumns = getColumns(aliasedThrough);
2131
+ const throughColumns = getColumns2(aliasedThrough);
1954
2132
  const key = junctionRef?._?.key;
1955
2133
  const byKey = key ? throughColumns[key] : void 0;
1956
2134
  if (byKey) {
@@ -1959,7 +2137,7 @@ var resolveJunctionColumn = (aliasedThrough, junctionRef, relationName) => {
1959
2137
  const columnName = junctionRef?._?.column?.name;
1960
2138
  const byName = columnName ? Object.values(throughColumns).find((c) => c.name === columnName) : void 0;
1961
2139
  if (!byName) {
1962
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2140
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
1963
2141
  }
1964
2142
  return byName;
1965
2143
  };
@@ -1968,15 +2146,15 @@ var buildThroughJoinConditions = (parentTable, relation, aliasedThrough, aliased
1968
2146
  const targetColumns = relation.targetColumns;
1969
2147
  const through = relation.through;
1970
2148
  if (!sourceColumns?.length || !targetColumns?.length || through?.source.length !== sourceColumns.length || through.target.length !== targetColumns.length) {
1971
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2149
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
1972
2150
  }
1973
- const parentColumns = Object.values(getColumns(parentTable));
1974
- const targetTableColumns = Object.values(getColumns(aliasedTarget));
2151
+ const parentColumns = Object.values(getColumns2(parentTable));
2152
+ const targetTableColumns = Object.values(getColumns2(aliasedTarget));
1975
2153
  const correlationConditions = [];
1976
2154
  for (let i = 0; i < sourceColumns.length; i++) {
1977
2155
  const localColumn = parentColumns.find((c) => c.name === sourceColumns[i].name);
1978
2156
  if (!localColumn) {
1979
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2157
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
1980
2158
  }
1981
2159
  correlationConditions.push(eq(localColumn, resolveJunctionColumn(aliasedThrough, through.source[i], relationName)));
1982
2160
  }
@@ -1984,7 +2162,7 @@ var buildThroughJoinConditions = (parentTable, relation, aliasedThrough, aliased
1984
2162
  for (let i = 0; i < targetColumns.length; i++) {
1985
2163
  const foreignColumn = targetTableColumns.find((c) => c.name === targetColumns[i].name);
1986
2164
  if (!foreignColumn) {
1987
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2165
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
1988
2166
  }
1989
2167
  junctionJoinConditions.push(
1990
2168
  eq(resolveJunctionColumn(aliasedThrough, through.target[i], relationName), foreignColumn)
@@ -2000,7 +2178,7 @@ var buildRelationExists = (parentTable, relationName, relEntry, innerFilters, mo
2000
2178
  const targetTable = ctx.tables[targetTableName];
2001
2179
  const relation = relEntry.relation ?? relEntry;
2002
2180
  if (!targetTable) {
2003
- throw new GraphQLError3(`WHERE ${relationName}: Relation cannot be used as a filter`);
2181
+ throw new GraphQLError4(`WHERE ${relationName}: Relation cannot be used as a filter`);
2004
2182
  }
2005
2183
  ctx.aliases ??= { n: 0 };
2006
2184
  const aliases = ctx.aliases;
@@ -2017,7 +2195,7 @@ var buildRelationExists = (parentTable, relationName, relEntry, innerFilters, mo
2017
2195
  aliasedTarget,
2018
2196
  relationName
2019
2197
  );
2020
- fromClause = sql`${getTableAsAliasSQL(aliasedTarget)} inner join ${getTableAsAliasSQL(aliasedThrough)} on ${junctionJoin}`;
2198
+ fromClause = sql2`${getTableAsAliasSQL(aliasedTarget)} inner join ${getTableAsAliasSQL(aliasedThrough)} on ${junctionJoin}`;
2021
2199
  joinCondition = correlation;
2022
2200
  } else {
2023
2201
  fromClause = getTableAsAliasSQL(aliasedTarget);
@@ -2029,10 +2207,10 @@ var buildRelationExists = (parentTable, relationName, relEntry, innerFilters, mo
2029
2207
  if (!inner) {
2030
2208
  return void 0;
2031
2209
  }
2032
- return sql`not exists (select 1 from ${fromClause} where ${and(joinCondition, relationWhere, not(inner))})`;
2210
+ return sql2`not exists (select 1 from ${fromClause} where ${and(joinCondition, relationWhere, not(inner))})`;
2033
2211
  }
2034
2212
  const condition = and(joinCondition, relationWhere, inner);
2035
- return mode === "none" ? sql`not exists (select 1 from ${fromClause} where ${condition})` : sql`exists (select 1 from ${fromClause} where ${condition})`;
2213
+ return mode === "none" ? sql2`not exists (select 1 from ${fromClause} where ${condition})` : sql2`exists (select 1 from ${fromClause} where ${condition})`;
2036
2214
  };
2037
2215
  var extractRelationFilter = (parentTable, relationName, relEntry, value, ctx) => {
2038
2216
  const relation = relEntry.relation ?? relEntry;
@@ -2046,7 +2224,7 @@ var extractRelationFilter = (parentTable, relationName, relEntry, value, ctx) =>
2046
2224
  continue;
2047
2225
  }
2048
2226
  if (!relationMatchModes.includes(mode)) {
2049
- throw new GraphQLError3(`WHERE ${relationName}: Unknown relation filter key: ${mode}`);
2227
+ throw new GraphQLError4(`WHERE ${relationName}: Unknown relation filter key: ${mode}`);
2050
2228
  }
2051
2229
  const extracted = buildRelationExists(parentTable, relationName, relEntry, inner, mode, ctx);
2052
2230
  if (extracted) {
@@ -2058,7 +2236,7 @@ var extractRelationFilter = (parentTable, relationName, relEntry, value, ctx) =>
2058
2236
  var extractFilters = (table, tableName, filters, relationCtx) => {
2059
2237
  const { OR, AND, NOT, ...fieldFilters } = filters;
2060
2238
  const entries = Object.entries(fieldFilters);
2061
- const columns = getColumns(table);
2239
+ const columns = getColumns2(table);
2062
2240
  const relations = relationCtx?.relationMap[relationCtx.tableKey];
2063
2241
  const variants = [];
2064
2242
  for (const [fieldName, operators] of entries) {
@@ -2067,7 +2245,7 @@ var extractFilters = (table, tableName, filters, relationCtx) => {
2067
2245
  }
2068
2246
  const column = columns[fieldName];
2069
2247
  if (!column && !(relations?.[fieldName] && relationCtx)) {
2070
- throw new GraphQLError3(`WHERE ${tableName}: Unknown filter key: ${fieldName}`);
2248
+ throw new GraphQLError4(`WHERE ${tableName}: Unknown filter key: ${fieldName}`);
2071
2249
  }
2072
2250
  const extracted = column ? extractFiltersColumn(column, fieldName, operators) : extractRelationFilter(table, fieldName, relations[fieldName], operators, relationCtx);
2073
2251
  if (extracted) {
@@ -2131,6 +2309,10 @@ var extractRelationsParamsInner = (relationMap, tables, tableName, typeName, ori
2131
2309
  if (!relFieldSelection) {
2132
2310
  continue;
2133
2311
  }
2312
+ const eagerArgs = field.args;
2313
+ if (!is3(relEntry.relation ?? relEntry, One2) && (eagerArgs?.after != null || !!eagerArgs?.distinct?.length || isCursorFieldSelected(relFieldSelection, tables[targetTableName]))) {
2314
+ continue;
2315
+ }
2134
2316
  const columns = extractSelectedColumnsFromTree(relFieldSelection, tables[targetTableName], {
2135
2317
  tableName: targetTableName,
2136
2318
  relationMap,
@@ -2183,7 +2365,7 @@ var pruneNonEagerRelations = (relationMap, shouldEagerLoad) => {
2183
2365
  return out;
2184
2366
  };
2185
2367
  var getPrimaryKeyPropNames = (table, compositePkColumnNames) => {
2186
- const cols = getColumns(table);
2368
+ const cols = getColumns2(table);
2187
2369
  const entries = Object.entries(cols);
2188
2370
  const inlinePks = entries.filter(([, c]) => c.primary).map(([k]) => k);
2189
2371
  if (inlinePks.length) {
@@ -2199,7 +2381,7 @@ var getPrimaryKeyPropNames = (table, compositePkColumnNames) => {
2199
2381
  return [];
2200
2382
  };
2201
2383
  var withPrimaryKeyColumns = (columns, table, pkNames) => {
2202
- const allCols = getColumns(table);
2384
+ const allCols = getColumns2(table);
2203
2385
  for (const pk of pkNames) {
2204
2386
  if (!(pk in columns) && allCols[pk]) {
2205
2387
  columns[pk] = allCols[pk];
@@ -2212,7 +2394,7 @@ var getPrimaryKeyPropNamesFromConfig = (table, getTableConfig4) => {
2212
2394
  return getPrimaryKeyPropNames(table, compositePkColumnNames);
2213
2395
  };
2214
2396
  var primaryKeyOrderExprs = (table, pkNames) => {
2215
- const cols = getColumns(table);
2397
+ const cols = getColumns2(table);
2216
2398
  return pkNames.map((n) => cols[n]).filter(Boolean).map((col) => asc(col));
2217
2399
  };
2218
2400
  var CURSOR_FIELD_NAME = "cursor";
@@ -2229,7 +2411,7 @@ var cursorOrderingEntries = (orderBy, pkNames) => {
2229
2411
  return entries;
2230
2412
  };
2231
2413
  var cursorOrderExprs = (table, entries) => {
2232
- const cols = getColumns(table);
2414
+ const cols = getColumns2(table);
2233
2415
  return entries.flatMap(
2234
2416
  ([column, direction, nulls]) => orderExpressions(cols[column], direction, nulls ?? void 0, cols[column])
2235
2417
  );
@@ -2266,10 +2448,10 @@ var decodeCursor = (after, entries) => {
2266
2448
  try {
2267
2449
  payload = JSON.parse(Buffer.from(after, "base64url").toString("utf8"));
2268
2450
  } catch (_e) {
2269
- throw new GraphQLError3("Invalid cursor: unable to decode it. Pass a cursor returned by a previous page.");
2451
+ throw new GraphQLError4("Invalid cursor: unable to decode it. Pass a cursor returned by a previous page.");
2270
2452
  }
2271
2453
  if (!payload || typeof payload !== "object" || !Array.isArray(payload.o) || !Array.isArray(payload.v) || payload.o.length !== payload.v.length) {
2272
- throw new GraphQLError3("Invalid cursor: malformed payload. Pass a cursor returned by a previous page.");
2454
+ throw new GraphQLError4("Invalid cursor: malformed payload. Pass a cursor returned by a previous page.");
2273
2455
  }
2274
2456
  const matchesOrdering = payload.o.length === entries.length && payload.o.every(
2275
2457
  (entry, i) => Array.isArray(entry) && entry[0] === entries[i][0] && entry[1] === entries[i][1] && // The nulls override changes where NULLs sort, so it is part of the ordering identity.
@@ -2277,20 +2459,20 @@ var decodeCursor = (after, entries) => {
2277
2459
  (entry[2] ?? null) === (entries[i][2] ?? null)
2278
2460
  );
2279
2461
  if (!matchesOrdering) {
2280
- throw new GraphQLError3(
2462
+ throw new GraphQLError4(
2281
2463
  "Invalid cursor: it was issued for a different ordering. Pass the same orderBy the cursor's page used."
2282
2464
  );
2283
2465
  }
2284
2466
  return payload.v.map(decodeCursorValue);
2285
2467
  };
2286
2468
  var buildCursorCondition = (table, entries, values, nullOrdering) => {
2287
- const cols = getColumns(table);
2469
+ const cols = getColumns2(table);
2288
2470
  const disjuncts = [];
2289
2471
  const equalities = [];
2290
2472
  entries.forEach(([column, direction, nulls], i) => {
2291
2473
  const col = cols[column];
2292
2474
  if (!col) {
2293
- throw new GraphQLError3(`Invalid cursor: unknown column '${column}'.`);
2475
+ throw new GraphQLError4(`Invalid cursor: unknown column '${column}'.`);
2294
2476
  }
2295
2477
  const value = values[i];
2296
2478
  const nullsSortLast = nulls != null ? nulls === "last" : direction === "asc" === (nullOrdering === "nulls-largest");
@@ -2307,7 +2489,7 @@ var buildCursorCondition = (table, entries, values, nullOrdering) => {
2307
2489
  equalities.push(value === null || value === void 0 ? isNull(col) : eq(col, value));
2308
2490
  });
2309
2491
  if (!disjuncts.length) {
2310
- return sql`1 = 0`;
2492
+ return sql2`1 = 0`;
2311
2493
  }
2312
2494
  return disjuncts.length > 1 ? or(...disjuncts) : disjuncts[0];
2313
2495
  };
@@ -2315,11 +2497,33 @@ var isCursorFieldSelected = (tree, table) => {
2315
2497
  if (!tree) {
2316
2498
  return false;
2317
2499
  }
2318
- if (getColumns(table)[CURSOR_FIELD_NAME]) {
2500
+ if (getColumns2(table)[CURSOR_FIELD_NAME]) {
2319
2501
  return false;
2320
2502
  }
2321
2503
  return Object.values(tree).some((field) => field.name === CURSOR_FIELD_NAME);
2322
2504
  };
2505
+ var selectsCursorField = (info, table) => {
2506
+ if (getColumns2(table)[CURSOR_FIELD_NAME]) {
2507
+ return false;
2508
+ }
2509
+ const visited = /* @__PURE__ */ new Set();
2510
+ const walk = (selections) => selections.some((selection) => {
2511
+ if (selection.kind === "Field") {
2512
+ return selection.name.value === CURSOR_FIELD_NAME;
2513
+ }
2514
+ if (selection.kind === "InlineFragment") {
2515
+ return walk(selection.selectionSet.selections);
2516
+ }
2517
+ const name = selection.name?.value;
2518
+ if (!name || visited.has(name)) {
2519
+ return false;
2520
+ }
2521
+ visited.add(name);
2522
+ const fragment = info.fragments?.[name];
2523
+ return fragment ? walk(fragment.selectionSet.selections) : false;
2524
+ });
2525
+ return (info.fieldNodes ?? []).some((node) => !!node.selectionSet && walk(node.selectionSet.selections));
2526
+ };
2323
2527
  var attachRowCursors = (rows, entries) => {
2324
2528
  for (const row of rows) {
2325
2529
  row[ROW_CURSOR_PROP] = encodeCursor(entries, row);
@@ -2327,7 +2531,7 @@ var attachRowCursors = (rows, entries) => {
2327
2531
  };
2328
2532
  var rowCursorResolver = (source) => source?.[ROW_CURSOR_PROP] ?? null;
2329
2533
  var getUniqueColumnSets = (table, getTableConfig4) => {
2330
- const cols = getColumns(table);
2534
+ const cols = getColumns2(table);
2331
2535
  const propNameByColumnName = new Map(Object.entries(cols).map(([propName, col]) => [col.name, propName]));
2332
2536
  const toPropNames = (columnNames) => {
2333
2537
  const propNames = [];
@@ -2372,7 +2576,7 @@ var generateColumnEnum = (table, enumName, description, predicate = () => true)
2372
2576
  if (cached) {
2373
2577
  return cached;
2374
2578
  }
2375
- const columnNames = Object.entries(getColumns(table)).filter(([columnName, column]) => predicate(column, columnName)).map(([columnName]) => columnName);
2579
+ const columnNames = Object.entries(getColumns2(table)).filter(([columnName, column]) => predicate(column, columnName)).map(([columnName]) => columnName);
2376
2580
  if (!columnNames.length) {
2377
2581
  return void 0;
2378
2582
  }
@@ -2414,7 +2618,7 @@ var generateOnConflictInput = (params) => {
2414
2618
  description: "Whether a conflicting row is overwritten or left alone. Defaults to UPDATE."
2415
2619
  },
2416
2620
  update: {
2417
- type: new GraphQLList2(new GraphQLNonNull2(updateEnum)),
2621
+ type: new GraphQLList3(new GraphQLNonNull3(updateEnum)),
2418
2622
  description: "Columns to overwrite on conflict. Defaults to every column the request supplied, minus the conflict target. Columns the request did not supply cannot be listed here \u2014 there would be no value to write."
2419
2623
  }
2420
2624
  };
@@ -2430,7 +2634,7 @@ var generateOnConflictInput = (params) => {
2430
2634
  return void 0;
2431
2635
  }
2432
2636
  fields["target"] = {
2433
- type: new GraphQLList2(new GraphQLNonNull2(targetEnum)),
2637
+ type: new GraphQLList3(new GraphQLNonNull3(targetEnum)),
2434
2638
  description: "The unique column set a conflict is detected on. Must match one of the table\u2019s unique constraints exactly. Defaults to the primary key."
2435
2639
  };
2436
2640
  fields["where"] = {
@@ -2438,7 +2642,7 @@ var generateOnConflictInput = (params) => {
2438
2642
  description: "Only overwrite conflicting rows that match this filter. Others are left alone."
2439
2643
  };
2440
2644
  }
2441
- return new GraphQLInputObjectType2({
2645
+ return new GraphQLInputObjectType3({
2442
2646
  name: `${typeName}OnConflict`,
2443
2647
  description: `Conflict handling for an upsert of ${typeName}`,
2444
2648
  fields
@@ -2446,18 +2650,18 @@ var generateOnConflictInput = (params) => {
2446
2650
  };
2447
2651
  var resolveConflictPlan = (params) => {
2448
2652
  const { table, values, onConflict, pkNames, uniqueSets, excludedRef, withTarget, buildWhere } = params;
2449
- const columns = getColumns(table);
2653
+ const columns = getColumns2(table);
2450
2654
  let target;
2451
2655
  if (withTarget) {
2452
2656
  const targetNames2 = onConflict?.target?.length ? onConflict.target : [...pkNames];
2453
2657
  if (!targetNames2.length) {
2454
- throw new GraphQLError3(
2658
+ throw new GraphQLError4(
2455
2659
  "Unable to upsert: no conflict target was given and this table has no primary key. Pass onConflict.target."
2456
2660
  );
2457
2661
  }
2458
2662
  const requested = [...targetNames2].sort().join(",");
2459
2663
  if (!uniqueSets.some((set2) => [...set2].sort().join(",") === requested)) {
2460
- throw new GraphQLError3(
2664
+ throw new GraphQLError4(
2461
2665
  `Unable to upsert: [${targetNames2.join(", ")}] is not a unique constraint on this table. Valid conflict targets: ${uniqueSets.map((set2) => `[${set2.join(", ")}]`).join(", ")}.`
2462
2666
  );
2463
2667
  }
@@ -2472,7 +2676,7 @@ var resolveConflictPlan = (params) => {
2472
2676
  if (onConflict?.update?.length) {
2473
2677
  const unsupplied = onConflict.update.filter((name) => !supplied.has(name));
2474
2678
  if (unsupplied.length) {
2475
- throw new GraphQLError3(
2679
+ throw new GraphQLError4(
2476
2680
  `Unable to upsert: onConflict.update lists ${unsupplied.join(", ")}, which the values do not supply.`
2477
2681
  );
2478
2682
  }
@@ -2487,18 +2691,19 @@ var resolveConflictPlan = (params) => {
2487
2691
  const setWhere = onConflict?.where && buildWhere ? buildWhere(onConflict.where) : void 0;
2488
2692
  return { action: "UPDATE", target, set, setWhere };
2489
2693
  };
2490
- var excludedColumnRef = (columnName) => sql`excluded.${sql.identifier(columnName)}`;
2491
- var mysqlValuesColumnRef = (columnName) => sql`values(${sql.identifier(columnName)})`;
2694
+ var excludedColumnRef = (columnName) => sql2`excluded.${sql2.identifier(columnName)}`;
2695
+ var mysqlValuesColumnRef = (columnName) => sql2`values(${sql2.identifier(columnName)})`;
2492
2696
  var selectDistinctKeys = async (params) => {
2493
- const { db, table, tableName, distinct, pkNames, where, orderBy, limit, offset } = params;
2494
- const cols = getColumns(table);
2697
+ const { db, table, tableName, distinct, pkNames, where, orderBy, limit, offset, partitionBy } = params;
2698
+ const cols = getColumns2(table);
2495
2699
  if (!pkNames.length) {
2496
- throw new GraphQLError3(`Table ${tableName} has no primary key, so 'distinct' cannot be applied to it.`);
2700
+ throw new GraphQLError4(`Table ${tableName} has no primary key, so 'distinct' cannot be applied to it.`);
2497
2701
  }
2498
- const partitionCols = distinct.map((name) => cols[name]).filter(Boolean);
2499
- if (!partitionCols.length) {
2500
- throw new GraphQLError3(`No known columns were given to 'distinct' on ${tableName}.`);
2702
+ const requestedCols = distinct.map((name) => cols[name]).filter(Boolean);
2703
+ if (!requestedCols.length) {
2704
+ throw new GraphQLError4(`No known columns were given to 'distinct' on ${tableName}.`);
2501
2705
  }
2706
+ const partitionCols = [...partitionBy ?? [], ...requestedCols];
2502
2707
  const orderEntries = orderBy ? orderByEntries(orderBy) : [];
2503
2708
  const windowOrder = [
2504
2709
  ...orderEntries.flatMap(
@@ -2506,9 +2711,9 @@ var selectDistinctKeys = async (params) => {
2506
2711
  ),
2507
2712
  ...primaryKeyOrderExprs(table, pkNames)
2508
2713
  ];
2509
- const rowNumber = sql`row_number() over (partition by ${sql.join(partitionCols, sql`, `)} order by ${sql.join(
2714
+ const rowNumber = sql2`row_number() over (partition by ${sql2.join(partitionCols, sql2`, `)} order by ${sql2.join(
2510
2715
  windowOrder,
2511
- sql`, `
2716
+ sql2`, `
2512
2717
  )})`.as(DISTINCT_RN);
2513
2718
  const sub = db.select({ ...cols, [DISTINCT_RN]: rowNumber }).from(table).where(where).as("__dgql_distinct");
2514
2719
  const outerOrder = [
@@ -2527,7 +2732,7 @@ var selectDistinctKeys = async (params) => {
2527
2732
  return await query;
2528
2733
  };
2529
2734
  var primaryKeyRestriction = (table, pkNames, keys) => {
2530
- const cols = getColumns(table);
2735
+ const cols = getColumns2(table);
2531
2736
  if (pkNames.length === 1) {
2532
2737
  const name = pkNames[0];
2533
2738
  return inArray(
@@ -2550,17 +2755,17 @@ var prepareMutationRelationColumns = (params) => {
2550
2755
  return { columns, hasRelations, withParams };
2551
2756
  };
2552
2757
  var toGraphQLError = (e) => {
2553
- if (e instanceof GraphQLError3) {
2758
+ if (e instanceof GraphQLError4) {
2554
2759
  return e;
2555
2760
  }
2556
- return e instanceof Error ? new GraphQLError3(e.message, { originalError: e }) : e;
2761
+ return e instanceof Error ? new GraphQLError4(e.message, { originalError: e }) : e;
2557
2762
  };
2558
2763
  var defaultErrorMapper = (error) => {
2559
- if (error instanceof GraphQLError3 && !error.originalError) {
2764
+ if (error instanceof GraphQLError4 && !error.originalError) {
2560
2765
  return error;
2561
2766
  }
2562
- return new GraphQLError3("Internal server error", {
2563
- originalError: error instanceof GraphQLError3 ? error.originalError ?? error : error instanceof Error ? error : null,
2767
+ return new GraphQLError4("Internal server error", {
2768
+ originalError: error instanceof GraphQLError4 ? error.originalError ?? error : error instanceof Error ? error : null,
2564
2769
  extensions: { code: "INTERNAL_SERVER_ERROR" }
2565
2770
  });
2566
2771
  };
@@ -2617,6 +2822,9 @@ var computeResolverFieldNames = (tableName, typeNameMapper, prefixes, suffixes)
2617
2822
  const writeSingleSuffix = suffixes.single === "" ? "Single" : suffixes.single;
2618
2823
  const updateSingleFieldName = `${updateFieldName}${writeSingleSuffix}`;
2619
2824
  const deleteSingleFieldName = `${deleteFieldName}${writeSingleSuffix}`;
2825
+ const pluralNoun = mapped ? capitalize(mapped.plural) : capitalize(tableName);
2826
+ const updateCountFieldName = `${prefixes.update}${pluralNoun}Count`;
2827
+ const deleteCountFieldName = `${prefixes.delete}${pluralNoun}Count`;
2620
2828
  return {
2621
2829
  typeName,
2622
2830
  listFieldName,
@@ -2630,13 +2838,15 @@ var computeResolverFieldNames = (tableName, typeNameMapper, prefixes, suffixes)
2630
2838
  updateFieldName,
2631
2839
  updateManyFieldName,
2632
2840
  updateSingleFieldName,
2841
+ updateCountFieldName,
2633
2842
  deleteFieldName,
2634
- deleteSingleFieldName
2843
+ deleteSingleFieldName,
2844
+ deleteCountFieldName
2635
2845
  };
2636
2846
  };
2637
2847
  var generateUpdateManyInput = (params) => {
2638
2848
  const { typeName, updatePrefix, updateInput, tableFilters } = params;
2639
- return new GraphQLInputObjectType2({
2849
+ return new GraphQLInputObjectType3({
2640
2850
  name: `${capitalize(updatePrefix)}${typeName}ManyInput`,
2641
2851
  description: `One entry of a batch update of ${typeName}: the rows \`where\` matches get this entry's \`set\` applied.`,
2642
2852
  fields: {
@@ -2645,7 +2855,7 @@ var generateUpdateManyInput = (params) => {
2645
2855
  description: "Rows this entry updates. An omitted filter updates every row."
2646
2856
  },
2647
2857
  set: {
2648
- type: new GraphQLNonNull2(updateInput)
2858
+ type: new GraphQLNonNull3(updateInput)
2649
2859
  }
2650
2860
  }
2651
2861
  });
@@ -2653,29 +2863,101 @@ var generateUpdateManyInput = (params) => {
2653
2863
  var extractRequiredFilters = (table, tableName, where, fieldName, relationCtx) => {
2654
2864
  const filters = where ? extractFilters(table, tableName, where, relationCtx) : void 0;
2655
2865
  if (!filters) {
2656
- throw new GraphQLError3(`${fieldName} requires a 'where' argument with at least one filter!`);
2866
+ throw new GraphQLError4(`${fieldName} requires a 'where' argument with at least one filter!`);
2657
2867
  }
2658
2868
  return filters;
2659
2869
  };
2870
+ var rowsAffected = (result, fieldName) => {
2871
+ const asNumber = (value) => typeof value === "number" ? value : typeof value === "bigint" ? Number(value) : void 0;
2872
+ if (result && typeof result === "object") {
2873
+ for (const key of ["rowCount", "affectedRows", "rowsAffected", "changes", "count"]) {
2874
+ const value = asNumber(result[key]);
2875
+ if (value !== void 0) {
2876
+ return value;
2877
+ }
2878
+ }
2879
+ const header = Array.isArray(result) ? result[0] : void 0;
2880
+ const affected = header && typeof header === "object" ? asNumber(header.affectedRows) : void 0;
2881
+ if (affected !== void 0) {
2882
+ return affected;
2883
+ }
2884
+ }
2885
+ throw new GraphQLError4(`${fieldName}: the driver did not report how many rows the write affected.`);
2886
+ };
2660
2887
  var assertSingleMatch = async (executor, table, filters, fieldName) => {
2661
- const matched = await executor.select({ found: sql`1` }).from(table).where(filters).limit(2);
2888
+ const matched = await executor.select({ found: sql2`1` }).from(table).where(filters).limit(2);
2662
2889
  if (matched.length > 1) {
2663
- throw new GraphQLError3(`${fieldName}: 'where' matched more than one row \u2014 nothing was written!`);
2664
- }
2890
+ throw new GraphQLError4(`${fieldName}: 'where' matched more than one row \u2014 nothing was written!`);
2891
+ }
2892
+ };
2893
+ var generateWriteCount = ({
2894
+ db,
2895
+ tableName,
2896
+ table,
2897
+ kind,
2898
+ setArgs,
2899
+ filterArgs,
2900
+ fieldName,
2901
+ requireWhere,
2902
+ filterCtx,
2903
+ txCtx,
2904
+ nested
2905
+ }) => {
2906
+ const queryArgs = {
2907
+ ...setArgs ? { set: { type: new GraphQLNonNull3(setArgs) } } : {},
2908
+ where: {
2909
+ type: requireWhere ? new GraphQLNonNull3(filterArgs) : filterArgs
2910
+ }
2911
+ };
2912
+ return {
2913
+ name: fieldName,
2914
+ resolver: async (_source, args, context, info) => {
2915
+ try {
2916
+ return await runMutation(db, context, info, txCtx, async (executor) => {
2917
+ const { where, set } = args;
2918
+ const relationCtx = relationFilterCtx(filterCtx, tableName);
2919
+ const filters = requireWhere ? extractRequiredFilters(table, tableName, where, fieldName, relationCtx) : where ? extractFilters(table, tableName, where, relationCtx) : void 0;
2920
+ let query;
2921
+ if (kind === "delete") {
2922
+ query = executor.delete(table);
2923
+ } else {
2924
+ const entry = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
2925
+ if (entry && nested.hasOps(entry.ops)) {
2926
+ throw new GraphQLError4(
2927
+ `${fieldName} does not support nested writes \u2014 use ${fieldName.slice(0, -"Count".length)} instead.`
2928
+ );
2929
+ }
2930
+ const values = remapUpdateInput(entry ? entry.columns : set, table, tableName);
2931
+ if (!Object.keys(values).length) {
2932
+ throw new GraphQLError4("Unable to update with no values specified!");
2933
+ }
2934
+ query = executor.update(table).set(values);
2935
+ }
2936
+ if (filters) {
2937
+ query = query.where(filters);
2938
+ }
2939
+ return rowsAffected(await query, fieldName);
2940
+ });
2941
+ } catch (e) {
2942
+ throw toGraphQLError(e);
2943
+ }
2944
+ },
2945
+ args: queryArgs
2946
+ };
2665
2947
  };
2666
2948
  var selectArrayArgs = (orderArgs, filterArgs, distinctEnum) => ({
2667
- offset: { type: GraphQLInt2 },
2668
- limit: { type: GraphQLInt2 },
2949
+ offset: { type: GraphQLInt3 },
2950
+ limit: { type: GraphQLInt3 },
2669
2951
  orderBy: { type: orderArgs },
2670
2952
  where: { type: filterArgs },
2671
2953
  after: {
2672
2954
  type: GraphQLString2,
2673
2955
  description: "Keyset pagination: only return rows strictly after this cursor (a row's `cursor` field from a previous page, under the same orderBy)."
2674
2956
  },
2675
- ...distinctEnum ? { distinct: { type: new GraphQLList2(new GraphQLNonNull2(distinctEnum)) } } : {}
2957
+ ...distinctEnum ? { distinct: { type: new GraphQLList3(new GraphQLNonNull3(distinctEnum)) } } : {}
2676
2958
  });
2677
2959
  var selectSingleArgs = (orderArgs, filterArgs) => ({
2678
- offset: { type: GraphQLInt2 },
2960
+ offset: { type: GraphQLInt3 },
2679
2961
  orderBy: { type: orderArgs },
2680
2962
  where: { type: filterArgs }
2681
2963
  });
@@ -2702,17 +2984,17 @@ var runRelationalSelect = async (opts) => {
2702
2984
  let cursorEntries;
2703
2985
  if (!single && (after != null || cursorSelected)) {
2704
2986
  if (after != null && distinct) {
2705
- throw new GraphQLError3("'after' cannot be combined with 'distinct'.");
2987
+ throw new GraphQLError4("'after' cannot be combined with 'distinct'.");
2706
2988
  }
2707
2989
  if (orderByHasRelationEntry(orderBy)) {
2708
2990
  if (after != null) {
2709
- throw new GraphQLError3(
2991
+ throw new GraphQLError4(
2710
2992
  "'after' cannot be combined with an orderBy that orders through a relation \u2014 a related row's value cannot be encoded into a cursor."
2711
2993
  );
2712
2994
  }
2713
2995
  } else if (!pkNames?.length) {
2714
2996
  if (after != null) {
2715
- throw new GraphQLError3(`Table ${tableName} has no primary key, so cursor pagination cannot be used on it.`);
2997
+ throw new GraphQLError4(`Table ${tableName} has no primary key, so cursor pagination cannot be used on it.`);
2716
2998
  }
2717
2999
  } else {
2718
3000
  cursorEntries = cursorOrderingEntries(orderBy, pkNames);
@@ -2809,20 +3091,20 @@ var eagerLoadMutationRelations = async (db, tableName, rows, pkNames, withParams
2809
3091
  whereRaw = (aliased) => inArray(aliased[pkName], ids);
2810
3092
  } else {
2811
3093
  whereRaw = (aliased) => {
2812
- const lhs = sql.join(
2813
- pkNames.map((n) => sql`${aliased[n]}`),
2814
- sql`, `
3094
+ const lhs = sql2.join(
3095
+ pkNames.map((n) => sql2`${aliased[n]}`),
3096
+ sql2`, `
2815
3097
  );
2816
- const tuples = sql.join(
3098
+ const tuples = sql2.join(
2817
3099
  keyableRows.map(
2818
- (row) => sql`(${sql.join(
2819
- pkNames.map((n) => sql`${row[n]}`),
2820
- sql`, `
3100
+ (row) => sql2`(${sql2.join(
3101
+ pkNames.map((n) => sql2`${row[n]}`),
3102
+ sql2`, `
2821
3103
  )})`
2822
3104
  ),
2823
- sql`, `
3105
+ sql2`, `
2824
3106
  );
2825
- return sql`(${lhs}) in (${tuples})`;
3107
+ return sql2`(${lhs}) in (${tuples})`;
2826
3108
  };
2827
3109
  }
2828
3110
  let enriched;
@@ -2857,9 +3139,10 @@ import { is as is4, One as One3 } from "drizzle-orm";
2857
3139
  import { getTableConfig, MySqlTable } from "drizzle-orm/mysql-core";
2858
3140
  import {
2859
3141
  GraphQLBoolean as GraphQLBoolean3,
2860
- GraphQLError as GraphQLError5,
2861
- GraphQLList as GraphQLList4,
2862
- GraphQLNonNull as GraphQLNonNull4,
3142
+ GraphQLError as GraphQLError6,
3143
+ GraphQLInt as GraphQLInt5,
3144
+ GraphQLList as GraphQLList5,
3145
+ GraphQLNonNull as GraphQLNonNull5,
2863
3146
  GraphQLObjectType as GraphQLObjectType4
2864
3147
  } from "graphql";
2865
3148
  import { parseResolveInfo as parseResolveInfo2 } from "graphql-parse-resolve-info";
@@ -2872,7 +3155,7 @@ import {
2872
3155
  countDistinct,
2873
3156
  eq as eq2,
2874
3157
  extractExtendedColumnType as extractExtendedColumnType3,
2875
- getColumns as getColumns2,
3158
+ getColumns as getColumns3,
2876
3159
  gt as gt2,
2877
3160
  gte as gte2,
2878
3161
  inArray as inArray2,
@@ -2884,12 +3167,12 @@ import {
2884
3167
  sum
2885
3168
  } from "drizzle-orm";
2886
3169
  import {
2887
- GraphQLError as GraphQLError4,
2888
- GraphQLFloat as GraphQLFloat3,
2889
- GraphQLInputObjectType as GraphQLInputObjectType3,
2890
- GraphQLInt as GraphQLInt3,
2891
- GraphQLList as GraphQLList3,
2892
- GraphQLNonNull as GraphQLNonNull3,
3170
+ GraphQLError as GraphQLError5,
3171
+ GraphQLFloat as GraphQLFloat4,
3172
+ GraphQLInputObjectType as GraphQLInputObjectType4,
3173
+ GraphQLInt as GraphQLInt4,
3174
+ GraphQLList as GraphQLList4,
3175
+ GraphQLNonNull as GraphQLNonNull4,
2893
3176
  GraphQLObjectType as GraphQLObjectType3
2894
3177
  } from "graphql";
2895
3178
  import { parseResolveInfo } from "graphql-parse-resolve-info";
@@ -2908,11 +3191,11 @@ var classifyAggregateColumns = (table, tableName) => {
2908
3191
  const numeric = {};
2909
3192
  const orderable = {};
2910
3193
  const all = {};
2911
- for (const [columnName, column] of Object.entries(getColumns2(table))) {
3194
+ for (const [columnName, column] of Object.entries(getColumns3(table))) {
2912
3195
  all[columnName] = column;
2913
3196
  const converted = drizzleColumnToGraphQLType(column, columnName, tableName, true, false, false);
2914
3197
  const gqlType = converted.type;
2915
- if (gqlType instanceof GraphQLList3 || gqlType instanceof GraphQLObjectType3) {
3198
+ if (gqlType instanceof GraphQLList4 || gqlType instanceof GraphQLObjectType3) {
2916
3199
  continue;
2917
3200
  }
2918
3201
  const { type: dataType, constraint } = extractExtendedColumnType3(column);
@@ -2936,14 +3219,14 @@ var generateAggregateTypes = (table, tableName, typeName, cacheCtx) => {
2936
3219
  }
2937
3220
  const { numeric, orderable, all } = classifyAggregateColumns(table, tableName);
2938
3221
  const fields = {
2939
- count: { type: new GraphQLNonNull3(GraphQLInt3) }
3222
+ count: { type: new GraphQLNonNull4(GraphQLInt4) }
2940
3223
  };
2941
3224
  if (Object.keys(numeric).length) {
2942
3225
  for (const op of ["avg", "sum"]) {
2943
3226
  fields[op] = {
2944
3227
  type: new GraphQLObjectType3({
2945
3228
  name: `${typeName}${capitalize(op)}Aggregate`,
2946
- fields: Object.fromEntries(Object.keys(numeric).map((columnName) => [columnName, { type: GraphQLFloat3 }]))
3229
+ fields: Object.fromEntries(Object.keys(numeric).map((columnName) => [columnName, { type: GraphQLFloat4 }]))
2947
3230
  })
2948
3231
  };
2949
3232
  }
@@ -2973,7 +3256,7 @@ var generateAggregateTypes = (table, tableName, typeName, cacheCtx) => {
2973
3256
  type: new GraphQLObjectType3({
2974
3257
  name: `${typeName}${capitalize(op)}Aggregate`,
2975
3258
  fields: Object.fromEntries(
2976
- columnNames.map((columnName) => [columnName, { type: new GraphQLNonNull3(GraphQLInt3) }])
3259
+ columnNames.map((columnName) => [columnName, { type: new GraphQLNonNull4(GraphQLInt4) }])
2977
3260
  )
2978
3261
  })
2979
3262
  };
@@ -3001,7 +3284,7 @@ var aggregateTarget = (table, tableName, typeName) => {
3001
3284
  return {
3002
3285
  tableName,
3003
3286
  typeName,
3004
- columns: getColumns2(table),
3287
+ columns: getColumns3(table),
3005
3288
  dateTimeColumns: new Set(
3006
3289
  Object.entries(orderable).filter(([, { converted }]) => converted.typeLabel === "DateTime").map(([columnName]) => columnName)
3007
3290
  )
@@ -3152,7 +3435,7 @@ var HAVING_OPS = { eq: eq2, ne: ne2, gt: gt2, gte: gte2, lt: lt2, lte: lte2 };
3152
3435
  var groupableColumns = (table, tableName) => {
3153
3436
  const { orderable } = classifyAggregateColumns(table, tableName);
3154
3437
  const groupable = { ...orderable };
3155
- for (const [columnName, column] of Object.entries(getColumns2(table))) {
3438
+ for (const [columnName, column] of Object.entries(getColumns3(table))) {
3156
3439
  if (groupable[columnName]) {
3157
3440
  continue;
3158
3441
  }
@@ -3176,10 +3459,10 @@ var generateGroupByEnum = (table, tableName, typeName) => {
3176
3459
  (_column, columnName) => Boolean(groupable[columnName])
3177
3460
  );
3178
3461
  };
3179
- var aggregateNumberFilter = new GraphQLInputObjectType3({
3462
+ var aggregateNumberFilter = new GraphQLInputObjectType4({
3180
3463
  name: "AggregateNumberFilter",
3181
3464
  description: "Compares an aggregated value. Several operators in one filter are ANDed together.",
3182
- fields: Object.fromEntries(Object.keys(HAVING_OPS).map((op) => [op, { type: GraphQLFloat3 }]))
3465
+ fields: Object.fromEntries(Object.keys(HAVING_OPS).map((op) => [op, { type: GraphQLFloat4 }]))
3183
3466
  });
3184
3467
  var generateHavingInput = (table, tableName, typeName) => {
3185
3468
  const { numeric, orderable, all } = classifyAggregateColumns(table, tableName);
@@ -3200,13 +3483,13 @@ var generateHavingInput = (table, tableName, typeName) => {
3200
3483
  continue;
3201
3484
  }
3202
3485
  fields[op] = {
3203
- type: new GraphQLInputObjectType3({
3486
+ type: new GraphQLInputObjectType4({
3204
3487
  name: `${typeName}${capitalize(op)}Having`,
3205
3488
  fields: Object.fromEntries(columnNames.map((columnName) => [columnName, { type: aggregateNumberFilter }]))
3206
3489
  })
3207
3490
  };
3208
3491
  }
3209
- return new GraphQLInputObjectType3({
3492
+ return new GraphQLInputObjectType4({
3210
3493
  name: `${typeName}Having`,
3211
3494
  description: `Filters ${typeName} groups by their aggregated values`,
3212
3495
  fields
@@ -3236,7 +3519,7 @@ var generateGroupByType = (table, tableName, typeName, cacheCtx) => {
3236
3519
  );
3237
3520
  return new GraphQLObjectType3({
3238
3521
  name: `${typeName}GroupBy`,
3239
- fields: { group: { type: new GraphQLNonNull3(keysType) }, ...aggregateFields }
3522
+ fields: { group: { type: new GraphQLNonNull4(keysType) }, ...aggregateFields }
3240
3523
  });
3241
3524
  };
3242
3525
  var havingComparisons = (expression, filter) => Object.entries(filter).filter(([op, value]) => value != null && op in HAVING_OPS).map(([op, value]) => HAVING_OPS[op](expression, value));
@@ -3269,11 +3552,11 @@ var buildHavingCondition = (having, columns) => {
3269
3552
  var generateGroupBy = (db, tableName, table, typeName, fieldName, filterArgs, groupByEnum, havingInput, filterCtx) => {
3270
3553
  const target = aggregateTarget(table, tableName, typeName);
3271
3554
  const groupable = groupableColumns(table, tableName);
3272
- const columns = getColumns2(table);
3555
+ const columns = getColumns3(table);
3273
3556
  const rootTypeName = `${typeName}GroupBy`;
3274
3557
  const queryArgs = {
3275
3558
  groupBy: {
3276
- type: new GraphQLNonNull3(new GraphQLList3(new GraphQLNonNull3(groupByEnum))),
3559
+ type: new GraphQLNonNull4(new GraphQLList4(new GraphQLNonNull4(groupByEnum))),
3277
3560
  description: "Columns to group by. One result row per distinct combination of their values."
3278
3561
  },
3279
3562
  where: { type: filterArgs, description: "Filters the rows before they are grouped." },
@@ -3285,12 +3568,12 @@ var generateGroupBy = (db, tableName, table, typeName, fieldName, filterArgs, gr
3285
3568
  try {
3286
3569
  const requestedKeys = [...new Set(args.groupBy ?? [])];
3287
3570
  if (!requestedKeys.length) {
3288
- throw new GraphQLError4("At least one column to group by is required!");
3571
+ throw new GraphQLError5("At least one column to group by is required!");
3289
3572
  }
3290
3573
  const keyColumns = requestedKeys.map((columnName) => {
3291
3574
  const groupableColumn = groupable[columnName];
3292
3575
  if (!groupableColumn) {
3293
- throw new GraphQLError4(`Cannot group ${typeName} by ${columnName}!`);
3576
+ throw new GraphQLError5(`Cannot group ${typeName} by ${columnName}!`);
3294
3577
  }
3295
3578
  return [columnName, groupableColumn.column];
3296
3579
  });
@@ -3412,7 +3695,7 @@ var generateSelectSingle = (db, tableName, tables, relationMap, orderArgs, filte
3412
3695
  var generateInsertArray = (db, _tableName, table, baseType, fieldName, txCtx) => {
3413
3696
  const queryArgs = {
3414
3697
  values: {
3415
- type: new GraphQLNonNull4(new GraphQLList4(new GraphQLNonNull4(baseType)))
3698
+ type: new GraphQLNonNull5(new GraphQLList5(new GraphQLNonNull5(baseType)))
3416
3699
  }
3417
3700
  };
3418
3701
  return {
@@ -3422,7 +3705,7 @@ var generateInsertArray = (db, _tableName, table, baseType, fieldName, txCtx) =>
3422
3705
  return await runMutation(db, context, info, txCtx, async (executor) => {
3423
3706
  const input = remapFromGraphQLArrayInput(args.values, table);
3424
3707
  if (!input.length) {
3425
- throw new GraphQLError5("No values were provided!");
3708
+ throw new GraphQLError6("No values were provided!");
3426
3709
  }
3427
3710
  await executor.insert(table).values(input);
3428
3711
  return { isSuccess: true };
@@ -3437,7 +3720,7 @@ var generateInsertArray = (db, _tableName, table, baseType, fieldName, txCtx) =>
3437
3720
  var generateInsertSingle = (db, _tableName, table, baseType, fieldName, txCtx) => {
3438
3721
  const queryArgs = {
3439
3722
  values: {
3440
- type: new GraphQLNonNull4(baseType)
3723
+ type: new GraphQLNonNull5(baseType)
3441
3724
  }
3442
3725
  };
3443
3726
  return {
@@ -3459,7 +3742,7 @@ var generateInsertSingle = (db, _tableName, table, baseType, fieldName, txCtx) =
3459
3742
  var generateUpsert = (db, table, baseType, onConflictType, fieldName, single, txCtx) => {
3460
3743
  const queryArgs = {
3461
3744
  values: {
3462
- type: single ? new GraphQLNonNull4(baseType) : new GraphQLNonNull4(new GraphQLList4(new GraphQLNonNull4(baseType)))
3745
+ type: single ? new GraphQLNonNull5(baseType) : new GraphQLNonNull5(new GraphQLList5(new GraphQLNonNull5(baseType)))
3463
3746
  },
3464
3747
  onConflict: {
3465
3748
  type: onConflictType,
@@ -3474,7 +3757,7 @@ var generateUpsert = (db, table, baseType, onConflictType, fieldName, single, tx
3474
3757
  return await runMutation(db, context, info, txCtx, async (executor) => {
3475
3758
  const input = single ? [remapFromGraphQLSingleInput(args.values, table)] : remapFromGraphQLArrayInput(args.values, table);
3476
3759
  if (!input.length) {
3477
- throw new GraphQLError5("No values were provided!");
3760
+ throw new GraphQLError6("No values were provided!");
3478
3761
  }
3479
3762
  const plan = resolveConflictPlan({
3480
3763
  table,
@@ -3502,10 +3785,10 @@ var generateUpsert = (db, table, baseType, onConflictType, fieldName, single, tx
3502
3785
  var generateUpdate = (db, tableName, table, setArgs, filterArgs, fieldName, single, requireWhere, filterCtx, txCtx) => {
3503
3786
  const queryArgs = {
3504
3787
  set: {
3505
- type: new GraphQLNonNull4(setArgs)
3788
+ type: new GraphQLNonNull5(setArgs)
3506
3789
  },
3507
3790
  where: {
3508
- type: single || requireWhere ? new GraphQLNonNull4(filterArgs) : filterArgs
3791
+ type: single || requireWhere ? new GraphQLNonNull5(filterArgs) : filterArgs
3509
3792
  }
3510
3793
  };
3511
3794
  return {
@@ -3514,9 +3797,9 @@ var generateUpdate = (db, tableName, table, setArgs, filterArgs, fieldName, sing
3514
3797
  try {
3515
3798
  return await runMutation(db, context, info, txCtx, async (executor) => {
3516
3799
  const { where, set } = args;
3517
- const input = remapFromGraphQLSingleInput(set, table);
3800
+ const input = remapUpdateInput(set, table, tableName);
3518
3801
  if (!Object.keys(input).length) {
3519
- throw new GraphQLError5("Unable to update with no values specified!");
3802
+ throw new GraphQLError6("Unable to update with no values specified!");
3520
3803
  }
3521
3804
  const relationCtx = relationFilterCtx(filterCtx, tableName);
3522
3805
  const filters = single || requireWhere ? extractRequiredFilters(table, tableName, where, fieldName, relationCtx) : where ? extractFilters(table, tableName, where, relationCtx) : void 0;
@@ -3540,7 +3823,7 @@ var generateUpdate = (db, tableName, table, setArgs, filterArgs, fieldName, sing
3540
3823
  var generateUpdateMany = (db, tableName, table, updateManyInput, fieldName, filterCtx, txCtx) => {
3541
3824
  const queryArgs = {
3542
3825
  updates: {
3543
- type: new GraphQLNonNull4(new GraphQLList4(new GraphQLNonNull4(updateManyInput)))
3826
+ type: new GraphQLNonNull5(new GraphQLList5(new GraphQLNonNull5(updateManyInput)))
3544
3827
  }
3545
3828
  };
3546
3829
  return {
@@ -3550,12 +3833,12 @@ var generateUpdateMany = (db, tableName, table, updateManyInput, fieldName, filt
3550
3833
  return await runMutation(db, context, info, txCtx, async (executor) => {
3551
3834
  const { updates } = args;
3552
3835
  if (!updates.length) {
3553
- throw new GraphQLError5("No updates were provided!");
3836
+ throw new GraphQLError6("No updates were provided!");
3554
3837
  }
3555
3838
  const entries = updates.map(({ where, set }) => {
3556
- const input = remapFromGraphQLSingleInput(set, table);
3839
+ const input = remapUpdateInput(set, table, tableName);
3557
3840
  if (!Object.keys(input).length) {
3558
- throw new GraphQLError5("Unable to update with no values specified!");
3841
+ throw new GraphQLError6("Unable to update with no values specified!");
3559
3842
  }
3560
3843
  return {
3561
3844
  set: input,
@@ -3583,7 +3866,7 @@ var generateUpdateMany = (db, tableName, table, updateManyInput, fieldName, filt
3583
3866
  var generateDelete = (db, tableName, table, filterArgs, fieldName, single, requireWhere, filterCtx, txCtx) => {
3584
3867
  const queryArgs = {
3585
3868
  where: {
3586
- type: single || requireWhere ? new GraphQLNonNull4(filterArgs) : filterArgs
3869
+ type: single || requireWhere ? new GraphQLNonNull5(filterArgs) : filterArgs
3587
3870
  }
3588
3871
  };
3589
3872
  return {
@@ -3634,7 +3917,12 @@ var generateSchemaData = (db, schema, relations, options) => {
3634
3917
  attachTargetPrimaryKeys(namedRelations, tables, mysqlPrimaryKeyPropNames);
3635
3918
  const eagerRelations = pruneNonEagerRelations(namedRelations, shouldEagerLoad);
3636
3919
  const filterCtx = { tables, relationMap: namedRelations };
3637
- const resolverFactory = createRelationResolverFactory(db, tables, filterCtx);
3920
+ const resolverFactory = createRelationResolverFactory(
3921
+ db,
3922
+ tables,
3923
+ "nulls-smallest",
3924
+ filterCtx
3925
+ );
3638
3926
  const cacheCtx = {
3639
3927
  genericFilterCache: /* @__PURE__ */ new Map(),
3640
3928
  objectTypeCache: /* @__PURE__ */ new Map(),
@@ -3648,7 +3936,8 @@ var generateSchemaData = (db, schema, relations, options) => {
3648
3936
  listRelationFilterCache: /* @__PURE__ */ new Map(),
3649
3937
  aggregateTypeCache: /* @__PURE__ */ new Map(),
3650
3938
  complexity,
3651
- docs: options.docs ?? {}
3939
+ docs: options.docs ?? {},
3940
+ features
3652
3941
  };
3653
3942
  const relationAggregateFactory = features.relationAggregates ? createRelationAggregateFactory(db, tables, cacheCtx, typeNameMapper, filterCtx) : void 0;
3654
3943
  const queries = {};
@@ -3676,7 +3965,7 @@ var generateSchemaData = (db, schema, relations, options) => {
3676
3965
  name: "MutationReturn",
3677
3966
  fields: {
3678
3967
  isSuccess: {
3679
- type: new GraphQLNonNull4(GraphQLBoolean3)
3968
+ type: new GraphQLNonNull5(GraphQLBoolean3)
3680
3969
  }
3681
3970
  }
3682
3971
  });
@@ -3701,8 +3990,10 @@ var generateSchemaData = (db, schema, relations, options) => {
3701
3990
  updateFieldName,
3702
3991
  updateManyFieldName,
3703
3992
  updateSingleFieldName,
3993
+ updateCountFieldName,
3704
3994
  deleteFieldName,
3705
- deleteSingleFieldName
3995
+ deleteSingleFieldName,
3996
+ deleteCountFieldName
3706
3997
  } = computeResolverFieldNames(tableName, typeNameMapper, prefixes, suffixes);
3707
3998
  const selectArrGenerated = generateSelectArray(
3708
3999
  db,
@@ -3826,6 +4117,29 @@ var generateSchemaData = (db, schema, relations, options) => {
3826
4117
  filterCtx,
3827
4118
  mutationTxCtx
3828
4119
  ) : void 0;
4120
+ const updateCountGenerated = features.update && features.countMutations ? generateWriteCount({
4121
+ db,
4122
+ tableName,
4123
+ table: schema[tableName],
4124
+ kind: "update",
4125
+ setArgs: updateInput,
4126
+ filterArgs: tableFilters,
4127
+ fieldName: updateCountFieldName,
4128
+ requireWhere: features.requireWhere,
4129
+ filterCtx,
4130
+ txCtx: mutationTxCtx
4131
+ }) : void 0;
4132
+ const deleteCountGenerated = features.delete && features.countMutations ? generateWriteCount({
4133
+ db,
4134
+ tableName,
4135
+ table: schema[tableName],
4136
+ kind: "delete",
4137
+ filterArgs: tableFilters,
4138
+ fieldName: deleteCountFieldName,
4139
+ requireWhere: features.requireWhere,
4140
+ filterCtx,
4141
+ txCtx: mutationTxCtx
4142
+ }) : void 0;
3829
4143
  const aggregateType = features.aggregates ? generateAggregateTypes(schema[tableName], tableName, typeName, cacheCtx) : void 0;
3830
4144
  const aggregateGenerated = features.aggregates ? generateAggregate(
3831
4145
  db,
@@ -3863,7 +4177,7 @@ var generateSchemaData = (db, schema, relations, options) => {
3863
4177
  };
3864
4178
  if (aggregateGenerated && aggregateType) {
3865
4179
  queries[aggregateGenerated.name] = {
3866
- type: new GraphQLNonNull4(aggregateType),
4180
+ type: new GraphQLNonNull5(aggregateType),
3867
4181
  args: aggregateGenerated.args,
3868
4182
  resolve: aggregateGenerated.resolver,
3869
4183
  ...complexity ? { extensions: { complexity: aggregateFieldComplexity(complexity) } } : {}
@@ -3871,7 +4185,7 @@ var generateSchemaData = (db, schema, relations, options) => {
3871
4185
  }
3872
4186
  if (groupByGenerated && groupByType) {
3873
4187
  queries[groupByGenerated.name] = {
3874
- type: new GraphQLNonNull4(new GraphQLList4(new GraphQLNonNull4(groupByType))),
4188
+ type: new GraphQLNonNull5(new GraphQLList5(new GraphQLNonNull5(groupByType))),
3875
4189
  args: groupByGenerated.args,
3876
4190
  resolve: groupByGenerated.resolver,
3877
4191
  ...complexity ? { extensions: { complexity: aggregateFieldComplexity(complexity) } } : {}
@@ -3896,6 +4210,22 @@ var generateSchemaData = (db, schema, relations, options) => {
3896
4210
  };
3897
4211
  }
3898
4212
  }
4213
+ if (updateCountGenerated) {
4214
+ mutations[updateCountGenerated.name] = {
4215
+ type: new GraphQLNonNull5(GraphQLInt5),
4216
+ args: updateCountGenerated.args,
4217
+ resolve: updateCountGenerated.resolver,
4218
+ description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
4219
+ };
4220
+ }
4221
+ if (deleteCountGenerated) {
4222
+ mutations[deleteCountGenerated.name] = {
4223
+ type: new GraphQLNonNull5(GraphQLInt5),
4224
+ args: deleteCountGenerated.args,
4225
+ resolve: deleteCountGenerated.resolver,
4226
+ description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
4227
+ };
4228
+ }
3899
4229
  const activeInputs = [
3900
4230
  // The insert input types the upsert mutations too, so either feature keeps it.
3901
4231
  ...features.insert || onConflictInput ? [insertInput] : [],
@@ -3940,23 +4270,24 @@ var generateSchemaData = (db, schema, relations, options) => {
3940
4270
  };
3941
4271
 
3942
4272
  // src/util/builders/pg.ts
3943
- import { and as and4, getColumns as getColumns4, is as is6, One as One5 } from "drizzle-orm";
4273
+ import { and as and4, getColumns as getColumns5, is as is6, One as One5 } from "drizzle-orm";
3944
4274
  import { getTableConfig as getTableConfig2, PgTable } from "drizzle-orm/pg-core";
3945
4275
  import {
3946
- GraphQLError as GraphQLError7,
3947
- GraphQLList as GraphQLList6,
3948
- GraphQLNonNull as GraphQLNonNull6
4276
+ GraphQLError as GraphQLError8,
4277
+ GraphQLInt as GraphQLInt6,
4278
+ GraphQLList as GraphQLList7,
4279
+ GraphQLNonNull as GraphQLNonNull7
3949
4280
  } from "graphql";
3950
4281
  import { parseResolveInfo as parseResolveInfo3 } from "graphql-parse-resolve-info";
3951
4282
 
3952
4283
  // src/util/builders/nested-writes.ts
3953
- import { and as and3, eq as eq3, getColumns as getColumns3, is as is5, One as One4 } from "drizzle-orm";
4284
+ import { and as and3, eq as eq3, getColumns as getColumns4, is as is5, One as One4 } from "drizzle-orm";
3954
4285
  import {
3955
4286
  GraphQLBoolean as GraphQLBoolean4,
3956
- GraphQLError as GraphQLError6,
3957
- GraphQLInputObjectType as GraphQLInputObjectType4,
3958
- GraphQLList as GraphQLList5,
3959
- GraphQLNonNull as GraphQLNonNull5
4287
+ GraphQLError as GraphQLError7,
4288
+ GraphQLInputObjectType as GraphQLInputObjectType5,
4289
+ GraphQLList as GraphQLList6,
4290
+ GraphQLNonNull as GraphQLNonNull6
3960
4291
  } from "graphql";
3961
4292
  var isOptionalOnInsert = (column) => !column.notNull || !!column.hasDefault || !!column.defaultFn;
3962
4293
  var buildNestedWritePlans = (tables, relationMap, resolveUniqueSets, resolvePrimaryKeys, extractJoinColumns) => {
@@ -4001,7 +4332,7 @@ var buildNestedWritePlans = (tables, relationMap, resolveUniqueSets, resolvePrim
4001
4332
  continue;
4002
4333
  }
4003
4334
  const { localColPropName, foreignCol, foreignColPropName } = joinColumns;
4004
- const localCol = getColumns3(table)[localColPropName];
4335
+ const localCol = getColumns4(table)[localColPropName];
4005
4336
  if (!localCol) {
4006
4337
  continue;
4007
4338
  }
@@ -4057,12 +4388,12 @@ var createNestedWriteTypes = (params) => {
4057
4388
  }
4058
4389
  const omitted = plan.fkSide === "child" ? plan.foreignColPropName : void 0;
4059
4390
  const fields = Object.fromEntries(
4060
- Object.entries(getColumns3(plan.targetTable)).filter(([columnName]) => columnName !== omitted).map(([columnName, column]) => [
4391
+ Object.entries(getColumns4(plan.targetTable)).filter(([columnName]) => columnName !== omitted).map(([columnName, column]) => [
4061
4392
  columnName,
4062
4393
  drizzleColumnToGraphQLType(column, columnName, plan.targetTableName, false, true, true)
4063
4394
  ])
4064
4395
  );
4065
- const type = new GraphQLInputObjectType4({
4396
+ const type = new GraphQLInputObjectType5({
4066
4397
  name: `${capitalize(insertPrefix)}${typeName}${capitalize(plan.relationName)}Input`,
4067
4398
  description: omitted === void 0 ? `A new ${resolveTypeName(plan.targetTableName, typeNameMapper)} row for ${typeName}.${plan.relationName}` : `A new ${resolveTypeName(plan.targetTableName, typeNameMapper)} row for ${typeName}.${plan.relationName}. \`${omitted}\` is set from the ${typeName} row this is written with.`,
4068
4399
  fields
@@ -4071,7 +4402,7 @@ var createNestedWriteTypes = (params) => {
4071
4402
  return type;
4072
4403
  };
4073
4404
  const targetFilters = (plan) => cacheCtx.filterTypeCache.get(plan.targetTable);
4074
- const listOf = (type) => new GraphQLList5(new GraphQLNonNull5(type));
4405
+ const listOf = (type) => new GraphQLList6(new GraphQLNonNull6(type));
4075
4406
  const wrapperType = (tableName, typeName, plan, forUpdate) => {
4076
4407
  const key = `${tableName}.${plan.relationName}.${forUpdate ? "update" : "create"}`;
4077
4408
  const cached = wrapperCache.get(key);
@@ -4115,7 +4446,7 @@ var createNestedWriteTypes = (params) => {
4115
4446
  }
4116
4447
  }
4117
4448
  }
4118
- const type = new GraphQLInputObjectType4({
4449
+ const type = new GraphQLInputObjectType5({
4119
4450
  name: `${typeName}${capitalize(plan.relationName)}Nested${forUpdate ? "Update" : "Create"}Input`,
4120
4451
  description: `Writes through ${typeName}.${plan.relationName}`,
4121
4452
  fields
@@ -4165,7 +4496,7 @@ var createNestedWriteRuntime = (params) => {
4165
4496
  relationFilterCtx(filterCtx, plan.targetTableName)
4166
4497
  );
4167
4498
  if (!condition) {
4168
- throw new GraphQLError6(
4499
+ throw new GraphQLError7(
4169
4500
  `Drizzle-GraphQL Error: '${operation}' on '${plan.relationName}' needs a filter that selects rows \u2014 it was given one that matches everything.`
4170
4501
  );
4171
4502
  }
@@ -4174,7 +4505,7 @@ var createNestedWriteRuntime = (params) => {
4174
4505
  const assertSingleOperation = (plan, op) => {
4175
4506
  const supplied = ["create", "connect", "disconnect"].filter((key) => op[key] !== void 0 && op[key] !== null);
4176
4507
  if (supplied.length > 1) {
4177
- throw new GraphQLError6(
4508
+ throw new GraphQLError7(
4178
4509
  `Drizzle-GraphQL Error: '${plan.relationName}' takes one of ${supplied.join(", ")} at a time \u2014 it holds a single row.`
4179
4510
  );
4180
4511
  }
@@ -4204,7 +4535,7 @@ var createNestedWriteRuntime = (params) => {
4204
4535
  if (!tablePlans) {
4205
4536
  return columns;
4206
4537
  }
4207
- const allColumns = getColumns3(table);
4538
+ const allColumns = getColumns4(table);
4208
4539
  for (const relationName of Object.keys(ops)) {
4209
4540
  const plan = tablePlans[relationName];
4210
4541
  if (plan?.fkSide === "child" && !(plan.localColPropName in columns) && allColumns[plan.localColPropName]) {
@@ -4230,7 +4561,7 @@ var createNestedWriteRuntime = (params) => {
4230
4561
  const inserted = await executor.insert(plan.targetTable).values(values).returning();
4231
4562
  const created = inserted[0];
4232
4563
  if (!created) {
4233
- throw new GraphQLError6(
4564
+ throw new GraphQLError7(
4234
4565
  `Drizzle-GraphQL Error: 'create' on '${relationName}' inserted no row, so there is nothing to attach.`
4235
4566
  );
4236
4567
  }
@@ -4238,7 +4569,7 @@ var createNestedWriteRuntime = (params) => {
4238
4569
  } else if (op["connect"] !== void 0) {
4239
4570
  const rows = await executor.select().from(plan.targetTable).where(conditionOf(plan, op["connect"], "connect"));
4240
4571
  if (rows.length !== 1) {
4241
- throw new GraphQLError6(
4572
+ throw new GraphQLError7(
4242
4573
  `Drizzle-GraphQL Error: 'connect' on '${relationName}' matched ${rows.length} rows \u2014 it attaches a single row, so its filter must match exactly one.`
4243
4574
  );
4244
4575
  }
@@ -4265,7 +4596,7 @@ var createNestedWriteRuntime = (params) => {
4265
4596
  for (const parentRow of parentRows) {
4266
4597
  const key = parentRow?.[plan.localColPropName];
4267
4598
  if (key === void 0 || key === null) {
4268
- throw new GraphQLError6(
4599
+ throw new GraphQLError7(
4269
4600
  `Drizzle-GraphQL Error: cannot write through '${relationName}': the ${tableName} row has no '${plan.localColPropName}' value to attach to.`
4270
4601
  );
4271
4602
  }
@@ -4377,24 +4708,24 @@ var generateSelectArray2 = (db, tableName, tables, relationMap, orderArgs, filte
4377
4708
  let cursorEntries;
4378
4709
  if (after != null || cursorSelected) {
4379
4710
  if (after != null && distinct?.length) {
4380
- throw new GraphQLError7("'after' cannot be combined with 'distinct'.");
4711
+ throw new GraphQLError8("'after' cannot be combined with 'distinct'.");
4381
4712
  }
4382
4713
  if (orderByHasRelationEntry(orderBy)) {
4383
4714
  if (after != null) {
4384
- throw new GraphQLError7(
4715
+ throw new GraphQLError8(
4385
4716
  "'after' cannot be combined with an orderBy that orders through a relation \u2014 a related row's value cannot be encoded into a cursor."
4386
4717
  );
4387
4718
  }
4388
4719
  } else if (!pkNames.length) {
4389
4720
  if (after != null) {
4390
- throw new GraphQLError7(
4721
+ throw new GraphQLError8(
4391
4722
  `Table ${tableName} has no primary key, so cursor pagination cannot be used on it.`
4392
4723
  );
4393
4724
  }
4394
4725
  } else {
4395
4726
  cursorEntries = cursorOrderingEntries(orderBy, pkNames);
4396
4727
  if (cursorSelected) {
4397
- const allColumns = getColumns4(table);
4728
+ const allColumns = getColumns5(table);
4398
4729
  for (const [column] of cursorEntries) {
4399
4730
  selectedColumnsSql[column] ??= allColumns[column];
4400
4731
  }
@@ -4517,7 +4848,7 @@ var pgPrimaryKeyPropNames = (table) => getPrimaryKeyPropNamesFromConfig(table, g
4517
4848
  var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
4518
4849
  const queryArgs = {
4519
4850
  values: {
4520
- type: new GraphQLNonNull6(new GraphQLList6(new GraphQLNonNull6(baseType)))
4851
+ type: new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(baseType)))
4521
4852
  }
4522
4853
  };
4523
4854
  const pkNames = pgPrimaryKeyPropNames(table);
@@ -4527,7 +4858,7 @@ var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType,
4527
4858
  try {
4528
4859
  return await runMutation(db, context, info, txCtx, async (executor) => {
4529
4860
  if (!args.values.length) {
4530
- throw new GraphQLError7("No values were provided!");
4861
+ throw new GraphQLError8("No values were provided!");
4531
4862
  }
4532
4863
  const entries = nested?.enabled(tableName) ? args.values.map((values) => nested.split(tableName, values)) : void 0;
4533
4864
  const nestedEntries = entries?.some((entry) => nested.hasOps(entry.ops)) ? entries : void 0;
@@ -4574,7 +4905,7 @@ var generateInsertArray2 = (db, tableName, table, tables, relationMap, baseType,
4574
4905
  var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
4575
4906
  const queryArgs = {
4576
4907
  values: {
4577
- type: new GraphQLNonNull6(baseType)
4908
+ type: new GraphQLNonNull7(baseType)
4578
4909
  }
4579
4910
  };
4580
4911
  const pkNames = pgPrimaryKeyPropNames(table);
@@ -4616,6 +4947,9 @@ var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType
4616
4947
  write: runInsert
4617
4948
  }) : await runInsert(executor, input);
4618
4949
  if (!result[0]) {
4950
+ if (!conflictDoNothing) {
4951
+ throw new GraphQLError8(`${fieldName}: the insert returned no row.`);
4952
+ }
4619
4953
  return void 0;
4620
4954
  }
4621
4955
  const enriched = hasRelations ? await eagerLoadMutationRelations(executor, tableName, result, pkNames, withParams) : result;
@@ -4631,7 +4965,7 @@ var generateInsertSingle2 = (db, tableName, table, tables, relationMap, baseType
4631
4965
  var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onConflictType, uniqueSets, fieldName, typeName, single, typeNameMapper, filterCtx, txCtx, nested) => {
4632
4966
  const queryArgs = {
4633
4967
  values: {
4634
- type: single ? new GraphQLNonNull6(baseType) : new GraphQLNonNull6(new GraphQLList6(new GraphQLNonNull6(baseType)))
4968
+ type: single ? new GraphQLNonNull7(baseType) : new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(baseType)))
4635
4969
  },
4636
4970
  onConflict: {
4637
4971
  type: onConflictType,
@@ -4646,7 +4980,7 @@ var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onCo
4646
4980
  return await runMutation(db, context, info, txCtx, async (executor) => {
4647
4981
  const supplied = single ? [args.values] : args.values;
4648
4982
  if (!supplied.length) {
4649
- throw new GraphQLError7("No values were provided!");
4983
+ throw new GraphQLError8("No values were provided!");
4650
4984
  }
4651
4985
  const entries = nested?.enabled(tableName) ? supplied.map((values) => nested.split(tableName, values)) : void 0;
4652
4986
  const nestedEntries = entries?.some((entry) => nested.hasOps(entry.ops)) ? entries : void 0;
@@ -4702,10 +5036,10 @@ var generateUpsert2 = (db, tableName, table, tables, relationMap, baseType, onCo
4702
5036
  var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filterArgs, fieldName, typeName, single, requireWhere, typeNameMapper, filterCtx, txCtx, nested) => {
4703
5037
  const queryArgs = {
4704
5038
  set: {
4705
- type: new GraphQLNonNull6(setArgs)
5039
+ type: new GraphQLNonNull7(setArgs)
4706
5040
  },
4707
5041
  where: {
4708
- type: single || requireWhere ? new GraphQLNonNull6(filterArgs) : filterArgs
5042
+ type: single || requireWhere ? new GraphQLNonNull7(filterArgs) : filterArgs
4709
5043
  }
4710
5044
  };
4711
5045
  const pkNames = pgPrimaryKeyPropNames(table);
@@ -4730,9 +5064,9 @@ var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filte
4730
5064
  });
4731
5065
  const entry = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
4732
5066
  const nestedOps = entry && nested.hasOps(entry.ops) ? entry.ops : void 0;
4733
- const input = remapFromGraphQLSingleInput(entry ? entry.columns : set, table);
5067
+ const input = remapUpdateInput(entry ? entry.columns : set, table, tableName);
4734
5068
  if (!Object.keys(input).length && !nestedOps) {
4735
- throw new GraphQLError7("Unable to update with no values specified!");
5069
+ throw new GraphQLError8("Unable to update with no values specified!");
4736
5070
  }
4737
5071
  const relationCtx = relationFilterCtx(filterCtx, tableName);
4738
5072
  const filters = single || requireWhere ? extractRequiredFilters(table, tableName, where, fieldName, relationCtx) : where ? extractFilters(table, tableName, where, relationCtx) : void 0;
@@ -4758,7 +5092,7 @@ var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filte
4758
5092
  write: runUpdate
4759
5093
  }) : await runUpdate(executor, input);
4760
5094
  if (single && result.length > 1) {
4761
- throw new GraphQLError7(`${fieldName}: 'where' matched more than one row!`);
5095
+ throw new GraphQLError8(`${fieldName}: 'where' matched more than one row!`);
4762
5096
  }
4763
5097
  if (single && !result[0]) {
4764
5098
  return void 0;
@@ -4776,7 +5110,7 @@ var generateUpdate2 = (db, tableName, table, tables, relationMap, setArgs, filte
4776
5110
  var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateManyInput, fieldName, typeName, typeNameMapper, filterCtx, txCtx, nested) => {
4777
5111
  const queryArgs = {
4778
5112
  updates: {
4779
- type: new GraphQLNonNull6(new GraphQLList6(new GraphQLNonNull6(updateManyInput)))
5113
+ type: new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(updateManyInput)))
4780
5114
  }
4781
5115
  };
4782
5116
  const pkNames = pgPrimaryKeyPropNames(table);
@@ -4787,7 +5121,7 @@ var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateMany
4787
5121
  return await runMutation(db, context, info, txCtx, async (executor) => {
4788
5122
  const { updates } = args;
4789
5123
  if (!updates.length) {
4790
- throw new GraphQLError7("No updates were provided!");
5124
+ throw new GraphQLError8("No updates were provided!");
4791
5125
  }
4792
5126
  const parsedInfo = parseResolveInfo3(info, {
4793
5127
  deep: true
@@ -4805,9 +5139,9 @@ var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateMany
4805
5139
  const entries = updates.map(({ where, set }) => {
4806
5140
  const split = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
4807
5141
  const ops = split && nested.hasOps(split.ops) ? split.ops : void 0;
4808
- const input = remapFromGraphQLSingleInput(split ? split.columns : set, table);
5142
+ const input = remapUpdateInput(split ? split.columns : set, table, tableName);
4809
5143
  if (!Object.keys(input).length && !ops) {
4810
- throw new GraphQLError7("Unable to update with no values specified!");
5144
+ throw new GraphQLError8("Unable to update with no values specified!");
4811
5145
  }
4812
5146
  return {
4813
5147
  set: input,
@@ -4866,7 +5200,7 @@ var generateUpdateMany2 = (db, tableName, table, tables, relationMap, updateMany
4866
5200
  var generateDelete2 = (db, tableName, table, filterArgs, fieldName, typeName, single, requireWhere, filterCtx, selectionCtx, txCtx) => {
4867
5201
  const queryArgs = {
4868
5202
  where: {
4869
- type: single || requireWhere ? new GraphQLNonNull6(filterArgs) : filterArgs
5203
+ type: single || requireWhere ? new GraphQLNonNull7(filterArgs) : filterArgs
4870
5204
  }
4871
5205
  };
4872
5206
  return {
@@ -4895,7 +5229,7 @@ var generateDelete2 = (db, tableName, table, filterArgs, fieldName, typeName, si
4895
5229
  query = query.returning(columns);
4896
5230
  const result = await query;
4897
5231
  if (single && result.length > 1) {
4898
- throw new GraphQLError7(`${fieldName}: 'where' matched more than one row!`);
5232
+ throw new GraphQLError8(`${fieldName}: 'where' matched more than one row!`);
4899
5233
  }
4900
5234
  if (single) {
4901
5235
  return result[0] ? remapToGraphQLSingleOutput(result[0], tableName, table) : void 0;
@@ -4934,7 +5268,12 @@ function generateSchemaData2(db, schema, relations, options) {
4934
5268
  attachTargetPrimaryKeys(namedRelations, tables, pgPrimaryKeyPropNames);
4935
5269
  const eagerRelations = pruneNonEagerRelations(namedRelations, shouldEagerLoad);
4936
5270
  const filterCtx = { tables, relationMap: namedRelations };
4937
- const resolverFactory = createRelationResolverFactory(db, tables, filterCtx);
5271
+ const resolverFactory = createRelationResolverFactory(
5272
+ db,
5273
+ tables,
5274
+ "nulls-largest",
5275
+ filterCtx
5276
+ );
4938
5277
  const cacheCtx = {
4939
5278
  genericFilterCache: /* @__PURE__ */ new Map(),
4940
5279
  objectTypeCache: /* @__PURE__ */ new Map(),
@@ -4948,7 +5287,8 @@ function generateSchemaData2(db, schema, relations, options) {
4948
5287
  listRelationFilterCache: /* @__PURE__ */ new Map(),
4949
5288
  aggregateTypeCache: /* @__PURE__ */ new Map(),
4950
5289
  complexity,
4951
- docs: options.docs ?? {}
5290
+ docs: options.docs ?? {},
5291
+ features
4952
5292
  };
4953
5293
  const nestedPlans = features.nestedWrites ? buildNestedWritePlans(
4954
5294
  tables,
@@ -5000,8 +5340,10 @@ function generateSchemaData2(db, schema, relations, options) {
5000
5340
  updateFieldName,
5001
5341
  updateManyFieldName,
5002
5342
  updateSingleFieldName,
5343
+ updateCountFieldName,
5003
5344
  deleteFieldName,
5004
- deleteSingleFieldName
5345
+ deleteSingleFieldName,
5346
+ deleteCountFieldName
5005
5347
  } = computeResolverFieldNames(tableName, typeNameMapper, prefixes, suffixes);
5006
5348
  const selectArrGenerated = generateSelectArray2(
5007
5349
  db,
@@ -5173,6 +5515,30 @@ function generateSchemaData2(db, schema, relations, options) {
5173
5515
  { tableName, relationMap: namedRelations, tables },
5174
5516
  mutationTxCtx
5175
5517
  ) : void 0;
5518
+ const updateCountGenerated = features.update && features.countMutations ? generateWriteCount({
5519
+ db,
5520
+ tableName,
5521
+ table: schema[tableName],
5522
+ kind: "update",
5523
+ setArgs: updateInput,
5524
+ filterArgs: tableFilters,
5525
+ fieldName: updateCountFieldName,
5526
+ requireWhere: features.requireWhere,
5527
+ filterCtx,
5528
+ txCtx: mutationTxCtx,
5529
+ nested: nestedRuntime
5530
+ }) : void 0;
5531
+ const deleteCountGenerated = features.delete && features.countMutations ? generateWriteCount({
5532
+ db,
5533
+ tableName,
5534
+ table: schema[tableName],
5535
+ kind: "delete",
5536
+ filterArgs: tableFilters,
5537
+ fieldName: deleteCountFieldName,
5538
+ requireWhere: features.requireWhere,
5539
+ filterCtx,
5540
+ txCtx: mutationTxCtx
5541
+ }) : void 0;
5176
5542
  const aggregateType = features.aggregates ? generateAggregateTypes(schema[tableName], tableName, typeName, cacheCtx) : void 0;
5177
5543
  const aggregateGenerated = features.aggregates ? generateAggregate(
5178
5544
  db,
@@ -5210,7 +5576,7 @@ function generateSchemaData2(db, schema, relations, options) {
5210
5576
  };
5211
5577
  if (aggregateGenerated && aggregateType) {
5212
5578
  queries[aggregateGenerated.name] = {
5213
- type: new GraphQLNonNull6(aggregateType),
5579
+ type: new GraphQLNonNull7(aggregateType),
5214
5580
  args: aggregateGenerated.args,
5215
5581
  resolve: aggregateGenerated.resolver,
5216
5582
  ...complexity ? { extensions: { complexity: aggregateFieldComplexity(complexity) } } : {}
@@ -5218,7 +5584,7 @@ function generateSchemaData2(db, schema, relations, options) {
5218
5584
  }
5219
5585
  if (groupByGenerated && groupByType) {
5220
5586
  queries[groupByGenerated.name] = {
5221
- type: new GraphQLNonNull6(new GraphQLList6(new GraphQLNonNull6(groupByType))),
5587
+ type: new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(groupByType))),
5222
5588
  args: groupByGenerated.args,
5223
5589
  resolve: groupByGenerated.resolver,
5224
5590
  ...complexity ? { extensions: { complexity: aggregateFieldComplexity(complexity) } } : {}
@@ -5233,7 +5599,9 @@ function generateSchemaData2(db, schema, relations, options) {
5233
5599
  }
5234
5600
  if (insertSingleGenerated) {
5235
5601
  mutations[insertSingleGenerated.name] = {
5236
- type: singleTableItemOutput,
5602
+ // An insert either returns the row it inserted or throws — the one path to `null` is
5603
+ // `conflictDoNothing` swallowing the insert, so the field is nullable only there.
5604
+ type: conflictDoNothing ? singleTableItemOutput : new GraphQLNonNull7(singleTableItemOutput),
5237
5605
  args: insertSingleGenerated.args,
5238
5606
  resolve: insertSingleGenerated.resolver
5239
5607
  };
@@ -5261,10 +5629,13 @@ function generateSchemaData2(db, schema, relations, options) {
5261
5629
  }
5262
5630
  if (updateManyGenerated) {
5263
5631
  mutations[updateManyGenerated.name] = {
5264
- // Nullable items: a no-match entry yields `null` in its slot.
5265
- type: new GraphQLNonNull6(new GraphQLList6(singleTableItemOutput)),
5632
+ type: new GraphQLNonNull7(new GraphQLList7(singleTableItemOutput)),
5266
5633
  args: updateManyGenerated.args,
5267
- resolve: updateManyGenerated.resolver
5634
+ resolve: updateManyGenerated.resolver,
5635
+ // The nullable element is deliberate, and the reason this mutation's return type
5636
+ // differs from every sibling's: the result is aligned with the input, one slot per
5637
+ // entry, so an entry that matched nothing has to be able to say so.
5638
+ description: "Each entry's updated rows, in entry order. An entry whose `where` matched no rows contributes `null` in its slot; an entry that matched several contributes each of its rows."
5268
5639
  };
5269
5640
  }
5270
5641
  if (updateSingleGenerated) {
@@ -5288,6 +5659,22 @@ function generateSchemaData2(db, schema, relations, options) {
5288
5659
  resolve: deleteSingleGenerated.resolver
5289
5660
  };
5290
5661
  }
5662
+ if (updateCountGenerated) {
5663
+ mutations[updateCountGenerated.name] = {
5664
+ type: new GraphQLNonNull7(GraphQLInt6),
5665
+ args: updateCountGenerated.args,
5666
+ resolve: updateCountGenerated.resolver,
5667
+ description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
5668
+ };
5669
+ }
5670
+ if (deleteCountGenerated) {
5671
+ mutations[deleteCountGenerated.name] = {
5672
+ type: new GraphQLNonNull7(GraphQLInt6),
5673
+ args: deleteCountGenerated.args,
5674
+ resolve: deleteCountGenerated.resolver,
5675
+ description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
5676
+ };
5677
+ }
5291
5678
  const activeInputs = [
5292
5679
  // The insert input types the upsert mutations too, so either feature keeps it.
5293
5680
  ...features.insert || onConflictInput ? [insertInput] : [],
@@ -5336,9 +5723,10 @@ function generateSchemaData2(db, schema, relations, options) {
5336
5723
  import { is as is7, One as One6 } from "drizzle-orm";
5337
5724
  import { getTableConfig as getTableConfig3, SQLiteTable } from "drizzle-orm/sqlite-core";
5338
5725
  import {
5339
- GraphQLError as GraphQLError8,
5340
- GraphQLList as GraphQLList7,
5341
- GraphQLNonNull as GraphQLNonNull7
5726
+ GraphQLError as GraphQLError9,
5727
+ GraphQLInt as GraphQLInt7,
5728
+ GraphQLList as GraphQLList8,
5729
+ GraphQLNonNull as GraphQLNonNull8
5342
5730
  } from "graphql";
5343
5731
  import { parseResolveInfo as parseResolveInfo4 } from "graphql-parse-resolve-info";
5344
5732
  var generateSelectArray3 = (db, tableName, tables, relationMap, orderArgs, filterArgs, fieldName, typeName, typeNameMapper, filterCtx, distinctEnabled = true) => {
@@ -5427,7 +5815,7 @@ var sqlitePrimaryKeyPropNames = (table) => getPrimaryKeyPropNamesFromConfig(tabl
5427
5815
  var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
5428
5816
  const queryArgs = {
5429
5817
  values: {
5430
- type: new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(baseType)))
5818
+ type: new GraphQLNonNull8(new GraphQLList8(new GraphQLNonNull8(baseType)))
5431
5819
  }
5432
5820
  };
5433
5821
  const pkNames = sqlitePrimaryKeyPropNames(table);
@@ -5437,7 +5825,7 @@ var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType,
5437
5825
  try {
5438
5826
  return await runMutation(db, context, info, txCtx, async (executor) => {
5439
5827
  if (!args.values.length) {
5440
- throw new GraphQLError8("No values were provided!");
5828
+ throw new GraphQLError9("No values were provided!");
5441
5829
  }
5442
5830
  const entries = nested?.enabled(tableName) ? args.values.map((values) => nested.split(tableName, values)) : void 0;
5443
5831
  const nestedEntries = entries?.some((entry) => nested.hasOps(entry.ops)) ? entries : void 0;
@@ -5484,7 +5872,7 @@ var generateInsertArray3 = (db, tableName, table, tables, relationMap, baseType,
5484
5872
  var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType, fieldName, typeName, typeNameMapper, conflictDoNothing = false, txCtx, nested) => {
5485
5873
  const queryArgs = {
5486
5874
  values: {
5487
- type: new GraphQLNonNull7(baseType)
5875
+ type: new GraphQLNonNull8(baseType)
5488
5876
  }
5489
5877
  };
5490
5878
  const pkNames = sqlitePrimaryKeyPropNames(table);
@@ -5526,6 +5914,9 @@ var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType
5526
5914
  write: runInsert
5527
5915
  }) : await runInsert(executor, input);
5528
5916
  if (!result[0]) {
5917
+ if (!conflictDoNothing) {
5918
+ throw new GraphQLError9(`${fieldName}: the insert returned no row.`);
5919
+ }
5529
5920
  return void 0;
5530
5921
  }
5531
5922
  const enriched = hasRelations ? await eagerLoadMutationRelations(executor, tableName, result, pkNames, withParams) : result;
@@ -5541,7 +5932,7 @@ var generateInsertSingle3 = (db, tableName, table, tables, relationMap, baseType
5541
5932
  var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onConflictType, uniqueSets, fieldName, typeName, single, typeNameMapper, filterCtx, txCtx, nested) => {
5542
5933
  const queryArgs = {
5543
5934
  values: {
5544
- type: single ? new GraphQLNonNull7(baseType) : new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(baseType)))
5935
+ type: single ? new GraphQLNonNull8(baseType) : new GraphQLNonNull8(new GraphQLList8(new GraphQLNonNull8(baseType)))
5545
5936
  },
5546
5937
  onConflict: {
5547
5938
  type: onConflictType,
@@ -5556,7 +5947,7 @@ var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onCo
5556
5947
  return await runMutation(db, context, info, txCtx, async (executor) => {
5557
5948
  const supplied = single ? [args.values] : args.values;
5558
5949
  if (!supplied.length) {
5559
- throw new GraphQLError8("No values were provided!");
5950
+ throw new GraphQLError9("No values were provided!");
5560
5951
  }
5561
5952
  const entries = nested?.enabled(tableName) ? supplied.map((values) => nested.split(tableName, values)) : void 0;
5562
5953
  const nestedEntries = entries?.some((entry) => nested.hasOps(entry.ops)) ? entries : void 0;
@@ -5612,10 +6003,10 @@ var generateUpsert3 = (db, tableName, table, tables, relationMap, baseType, onCo
5612
6003
  var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filterArgs, fieldName, typeName, single, requireWhere, typeNameMapper, filterCtx, txCtx, nested) => {
5613
6004
  const queryArgs = {
5614
6005
  set: {
5615
- type: new GraphQLNonNull7(setArgs)
6006
+ type: new GraphQLNonNull8(setArgs)
5616
6007
  },
5617
6008
  where: {
5618
- type: single || requireWhere ? new GraphQLNonNull7(filterArgs) : filterArgs
6009
+ type: single || requireWhere ? new GraphQLNonNull8(filterArgs) : filterArgs
5619
6010
  }
5620
6011
  };
5621
6012
  const pkNames = sqlitePrimaryKeyPropNames(table);
@@ -5640,9 +6031,9 @@ var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filte
5640
6031
  });
5641
6032
  const entry = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
5642
6033
  const nestedOps = entry && nested.hasOps(entry.ops) ? entry.ops : void 0;
5643
- const input = remapFromGraphQLSingleInput(entry ? entry.columns : set, table);
6034
+ const input = remapUpdateInput(entry ? entry.columns : set, table, tableName);
5644
6035
  if (!Object.keys(input).length && !nestedOps) {
5645
- throw new GraphQLError8("Unable to update with no values specified!");
6036
+ throw new GraphQLError9("Unable to update with no values specified!");
5646
6037
  }
5647
6038
  const relationCtx = relationFilterCtx(filterCtx, tableName);
5648
6039
  const filters = single || requireWhere ? extractRequiredFilters(table, tableName, where, fieldName, relationCtx) : where ? extractFilters(table, tableName, where, relationCtx) : void 0;
@@ -5668,7 +6059,7 @@ var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filte
5668
6059
  write: runUpdate
5669
6060
  }) : await runUpdate(executor, input);
5670
6061
  if (single && result.length > 1) {
5671
- throw new GraphQLError8(`${fieldName}: 'where' matched more than one row!`);
6062
+ throw new GraphQLError9(`${fieldName}: 'where' matched more than one row!`);
5672
6063
  }
5673
6064
  if (single && !result[0]) {
5674
6065
  return void 0;
@@ -5686,7 +6077,7 @@ var generateUpdate3 = (db, tableName, table, tables, relationMap, setArgs, filte
5686
6077
  var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateManyInput, fieldName, typeName, typeNameMapper, filterCtx, txCtx, nested) => {
5687
6078
  const queryArgs = {
5688
6079
  updates: {
5689
- type: new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(updateManyInput)))
6080
+ type: new GraphQLNonNull8(new GraphQLList8(new GraphQLNonNull8(updateManyInput)))
5690
6081
  }
5691
6082
  };
5692
6083
  const pkNames = sqlitePrimaryKeyPropNames(table);
@@ -5697,7 +6088,7 @@ var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateMany
5697
6088
  return await runMutation(db, context, info, txCtx, async (executor) => {
5698
6089
  const { updates } = args;
5699
6090
  if (!updates.length) {
5700
- throw new GraphQLError8("No updates were provided!");
6091
+ throw new GraphQLError9("No updates were provided!");
5701
6092
  }
5702
6093
  const parsedInfo = parseResolveInfo4(info, {
5703
6094
  deep: true
@@ -5715,9 +6106,9 @@ var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateMany
5715
6106
  const entries = updates.map(({ where, set }) => {
5716
6107
  const split = nested?.enabled(tableName) ? nested.split(tableName, set) : void 0;
5717
6108
  const ops = split && nested.hasOps(split.ops) ? split.ops : void 0;
5718
- const input = remapFromGraphQLSingleInput(split ? split.columns : set, table);
6109
+ const input = remapUpdateInput(split ? split.columns : set, table, tableName);
5719
6110
  if (!Object.keys(input).length && !ops) {
5720
- throw new GraphQLError8("Unable to update with no values specified!");
6111
+ throw new GraphQLError9("Unable to update with no values specified!");
5721
6112
  }
5722
6113
  return {
5723
6114
  set: input,
@@ -5804,7 +6195,7 @@ var generateUpdateMany3 = (db, tableName, table, tables, relationMap, updateMany
5804
6195
  var generateDelete3 = (db, tableName, table, filterArgs, fieldName, typeName, single, requireWhere, filterCtx, selectionCtx, txCtx) => {
5805
6196
  const queryArgs = {
5806
6197
  where: {
5807
- type: single || requireWhere ? new GraphQLNonNull7(filterArgs) : filterArgs
6198
+ type: single || requireWhere ? new GraphQLNonNull8(filterArgs) : filterArgs
5808
6199
  }
5809
6200
  };
5810
6201
  return {
@@ -5833,7 +6224,7 @@ var generateDelete3 = (db, tableName, table, filterArgs, fieldName, typeName, si
5833
6224
  query = query.returning(columns);
5834
6225
  const result = await query;
5835
6226
  if (single && result.length > 1) {
5836
- throw new GraphQLError8(`${fieldName}: 'where' matched more than one row!`);
6227
+ throw new GraphQLError9(`${fieldName}: 'where' matched more than one row!`);
5837
6228
  }
5838
6229
  if (single) {
5839
6230
  return result[0] ? remapToGraphQLSingleOutput(result[0], tableName, table) : void 0;
@@ -5873,7 +6264,12 @@ var generateSchemaData3 = (db, schema, relations, options) => {
5873
6264
  attachTargetPrimaryKeys(namedRelations, tables, sqlitePrimaryKeyPropNames);
5874
6265
  const eagerRelations = pruneNonEagerRelations(namedRelations, shouldEagerLoad);
5875
6266
  const filterCtx = { tables, relationMap: namedRelations };
5876
- const resolverFactory = createRelationResolverFactory(db, tables, filterCtx);
6267
+ const resolverFactory = createRelationResolverFactory(
6268
+ db,
6269
+ tables,
6270
+ "nulls-smallest",
6271
+ filterCtx
6272
+ );
5877
6273
  const cacheCtx = {
5878
6274
  genericFilterCache: /* @__PURE__ */ new Map(),
5879
6275
  objectTypeCache: /* @__PURE__ */ new Map(),
@@ -5887,7 +6283,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
5887
6283
  listRelationFilterCache: /* @__PURE__ */ new Map(),
5888
6284
  aggregateTypeCache: /* @__PURE__ */ new Map(),
5889
6285
  complexity,
5890
- docs: options.docs ?? {}
6286
+ docs: options.docs ?? {},
6287
+ features
5891
6288
  };
5892
6289
  if (features.nestedWrites && db.resultKind === "sync") {
5893
6290
  throw new Error(
@@ -5949,8 +6346,10 @@ var generateSchemaData3 = (db, schema, relations, options) => {
5949
6346
  updateFieldName,
5950
6347
  updateManyFieldName,
5951
6348
  updateSingleFieldName,
6349
+ updateCountFieldName,
5952
6350
  deleteFieldName,
5953
- deleteSingleFieldName
6351
+ deleteSingleFieldName,
6352
+ deleteCountFieldName
5954
6353
  } = computeResolverFieldNames(tableName, typeNameMapper, prefixes, suffixes);
5955
6354
  const selectArrGenerated = generateSelectArray3(
5956
6355
  db,
@@ -6122,6 +6521,30 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6122
6521
  { tableName, relationMap: namedRelations, tables },
6123
6522
  mutationTxCtx
6124
6523
  ) : void 0;
6524
+ const updateCountGenerated = features.update && features.countMutations ? generateWriteCount({
6525
+ db,
6526
+ tableName,
6527
+ table: schema[tableName],
6528
+ kind: "update",
6529
+ setArgs: updateInput,
6530
+ filterArgs: tableFilters,
6531
+ fieldName: updateCountFieldName,
6532
+ requireWhere: features.requireWhere,
6533
+ filterCtx,
6534
+ txCtx: mutationTxCtx,
6535
+ nested: nestedRuntime
6536
+ }) : void 0;
6537
+ const deleteCountGenerated = features.delete && features.countMutations ? generateWriteCount({
6538
+ db,
6539
+ tableName,
6540
+ table: schema[tableName],
6541
+ kind: "delete",
6542
+ filterArgs: tableFilters,
6543
+ fieldName: deleteCountFieldName,
6544
+ requireWhere: features.requireWhere,
6545
+ filterCtx,
6546
+ txCtx: mutationTxCtx
6547
+ }) : void 0;
6125
6548
  const aggregateType = features.aggregates ? generateAggregateTypes(schema[tableName], tableName, typeName, cacheCtx) : void 0;
6126
6549
  const aggregateGenerated = features.aggregates ? generateAggregate(
6127
6550
  db,
@@ -6159,7 +6582,7 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6159
6582
  };
6160
6583
  if (aggregateGenerated && aggregateType) {
6161
6584
  queries[aggregateGenerated.name] = {
6162
- type: new GraphQLNonNull7(aggregateType),
6585
+ type: new GraphQLNonNull8(aggregateType),
6163
6586
  args: aggregateGenerated.args,
6164
6587
  resolve: aggregateGenerated.resolver,
6165
6588
  ...complexity ? { extensions: { complexity: aggregateFieldComplexity(complexity) } } : {}
@@ -6167,7 +6590,7 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6167
6590
  }
6168
6591
  if (groupByGenerated && groupByType) {
6169
6592
  queries[groupByGenerated.name] = {
6170
- type: new GraphQLNonNull7(new GraphQLList7(new GraphQLNonNull7(groupByType))),
6593
+ type: new GraphQLNonNull8(new GraphQLList8(new GraphQLNonNull8(groupByType))),
6171
6594
  args: groupByGenerated.args,
6172
6595
  resolve: groupByGenerated.resolver,
6173
6596
  ...complexity ? { extensions: { complexity: aggregateFieldComplexity(complexity) } } : {}
@@ -6182,7 +6605,9 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6182
6605
  }
6183
6606
  if (insertSingleGenerated) {
6184
6607
  mutations[insertSingleGenerated.name] = {
6185
- type: singleTableItemOutput,
6608
+ // An insert either returns the row it inserted or throws — the one path to `null` is
6609
+ // `conflictDoNothing` swallowing the insert, so the field is nullable only there.
6610
+ type: conflictDoNothing ? singleTableItemOutput : new GraphQLNonNull8(singleTableItemOutput),
6186
6611
  args: insertSingleGenerated.args,
6187
6612
  resolve: insertSingleGenerated.resolver
6188
6613
  };
@@ -6210,10 +6635,13 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6210
6635
  }
6211
6636
  if (updateManyGenerated) {
6212
6637
  mutations[updateManyGenerated.name] = {
6213
- // Nullable items: a no-match entry yields `null` in its slot.
6214
- type: new GraphQLNonNull7(new GraphQLList7(singleTableItemOutput)),
6638
+ type: new GraphQLNonNull8(new GraphQLList8(singleTableItemOutput)),
6215
6639
  args: updateManyGenerated.args,
6216
- resolve: updateManyGenerated.resolver
6640
+ resolve: updateManyGenerated.resolver,
6641
+ // The nullable element is deliberate, and the reason this mutation's return type
6642
+ // differs from every sibling's: the result is aligned with the input, one slot per
6643
+ // entry, so an entry that matched nothing has to be able to say so.
6644
+ description: "Each entry's updated rows, in entry order. An entry whose `where` matched no rows contributes `null` in its slot; an entry that matched several contributes each of its rows."
6217
6645
  };
6218
6646
  }
6219
6647
  if (updateSingleGenerated) {
@@ -6237,6 +6665,22 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6237
6665
  resolve: deleteSingleGenerated.resolver
6238
6666
  };
6239
6667
  }
6668
+ if (updateCountGenerated) {
6669
+ mutations[updateCountGenerated.name] = {
6670
+ type: new GraphQLNonNull8(GraphQLInt7),
6671
+ args: updateCountGenerated.args,
6672
+ resolve: updateCountGenerated.resolver,
6673
+ description: "How many rows the update touched. The rows themselves are not read back, which is the point of this mutation."
6674
+ };
6675
+ }
6676
+ if (deleteCountGenerated) {
6677
+ mutations[deleteCountGenerated.name] = {
6678
+ type: new GraphQLNonNull8(GraphQLInt7),
6679
+ args: deleteCountGenerated.args,
6680
+ resolve: deleteCountGenerated.resolver,
6681
+ description: "How many rows the delete removed. The rows themselves are not read back, which is the point of this mutation."
6682
+ };
6683
+ }
6240
6684
  const activeInputs = [
6241
6685
  // The insert input types the upsert mutations too, so either feature keeps it.
6242
6686
  ...features.insert || onConflictInput ? [insertInput] : [],
@@ -6314,6 +6758,8 @@ var buildSchema = (db, config) => {
6314
6758
  delete: config?.features?.delete ?? true,
6315
6759
  upsert: config?.features?.upsert ?? false,
6316
6760
  nestedWrites: config?.features?.nestedWrites ?? false,
6761
+ fieldUpdateOperations: config?.features?.fieldUpdateOperations ?? false,
6762
+ countMutations: config?.features?.countMutations ?? false,
6317
6763
  requireWhere: config?.features?.requireWhere ?? false
6318
6764
  };
6319
6765
  const complexityConfig = config?.complexity ?? true;