@vantreeseba/drizzle-graphql 7.1.0 → 7.2.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.d.cts CHANGED
@@ -794,6 +794,21 @@ type LimitsConfig = TableLimitPolicy & {
794
794
  /** Per-table overrides, keyed by the table's key in the Drizzle schema. */
795
795
  tables?: Record<string, TableLimitPolicy>;
796
796
  };
797
+ /**
798
+ * {@link BuildSchemaConfig.exclude} — tables and columns to keep out of the generated schema.
799
+ *
800
+ * Both lists are keyed by the Drizzle schema key, not the database name and not the generated
801
+ * GraphQL name.
802
+ */
803
+ type SchemaExclusions = {
804
+ /**
805
+ * Tables that generate nothing at all: no object type, no queries, no mutations, and no
806
+ * relation fields on other tables that point at them.
807
+ */
808
+ tables?: string[];
809
+ /** Per-table column exclusions, keyed by the table's key in the Drizzle schema. */
810
+ columns?: Record<string, string[]>;
811
+ };
797
812
  type BuildSchemaConfig = {
798
813
  /**
799
814
  * Determines whether generated mutations will be passed to returned schema.
@@ -982,6 +997,36 @@ type BuildSchemaConfig = {
982
997
  * agree.
983
998
  */
984
999
  limits?: LimitsConfig;
1000
+ /**
1001
+ * Tables and columns to leave out of the generated schema entirely.
1002
+ *
1003
+ * ```ts
1004
+ * buildSchema(db, {
1005
+ * exclude: {
1006
+ * tables: ['magicLinks', 'sessions'],
1007
+ * columns: { apiKeys: ['keyHash'] },
1008
+ * },
1009
+ * });
1010
+ * ```
1011
+ *
1012
+ * An excluded **table** generates nothing: no object type, no root queries or mutations, no
1013
+ * aggregates, and no relation field on any other table that points at it. Filtering another
1014
+ * table by a relation to it is gone too, so it is unreachable rather than merely unnamed.
1015
+ *
1016
+ * An excluded **column** disappears from every surface at once — the object type, the
1017
+ * create/update/upsert inputs, the filter type, `orderBy`, the aggregate fields, the
1018
+ * `distinct` and `groupBy` enums, and the upsert conflict targets. The exclusion is
1019
+ * deliberately all-or-nothing: a column you can filter on but not select is an oracle, since
1020
+ * `where: { keyHash: { eq: '…' } }` confirms a value without ever returning it.
1021
+ *
1022
+ * Excluding a `NOT NULL` column that has no default makes that table's inserts impossible to
1023
+ * satisfy — `buildSchema` warns on the console when it sees this, and still builds, since a
1024
+ * read-only table is a reasonable thing to want.
1025
+ *
1026
+ * Names that match nothing throw, so a renamed column fails the build instead of quietly
1027
+ * un-hiding itself.
1028
+ */
1029
+ exclude?: SchemaExclusions;
985
1030
  /**
986
1031
  * Optional mapper from table key to singular/plural name pair.
987
1032
  * When provided for a table, overrides the default (table key) naming for GraphQL type names,
@@ -1210,4 +1255,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
1210
1255
 
1211
1256
  declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
1212
1257
 
1213
- export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ColumnDeprecator, type ColumnDescriber, type ColumnDocInfo, type ColumnTypeMapper, type ColumnTypeMapperInfo, type ComplexityConfig, type DeleteResolver, type DeleteSingleResolver, type EnumNameInfo, type EnumNameMapper, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, GraphQLDecimalString, type InsertArrResolver, type InsertResolver, type LimitsConfig, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationDescriber, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaDocs, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableDescriber, type TableLimitPolicy, type TableNamedRelations, type UpdateManyArgs, type UpdateManyEntry, type UpdateManyResolver, type UpdateResolver, type UpdateSingleResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
1258
+ export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ColumnDeprecator, type ColumnDescriber, type ColumnDocInfo, type ColumnTypeMapper, type ColumnTypeMapperInfo, type ComplexityConfig, type DeleteResolver, type DeleteSingleResolver, type EnumNameInfo, type EnumNameMapper, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, GraphQLDecimalString, type InsertArrResolver, type InsertResolver, type LimitsConfig, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationDescriber, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaDocs, type SchemaExclusions, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableDescriber, type TableLimitPolicy, type TableNamedRelations, type UpdateManyArgs, type UpdateManyEntry, type UpdateManyResolver, type UpdateResolver, type UpdateSingleResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
package/dist/index.d.ts CHANGED
@@ -794,6 +794,21 @@ type LimitsConfig = TableLimitPolicy & {
794
794
  /** Per-table overrides, keyed by the table's key in the Drizzle schema. */
795
795
  tables?: Record<string, TableLimitPolicy>;
796
796
  };
797
+ /**
798
+ * {@link BuildSchemaConfig.exclude} — tables and columns to keep out of the generated schema.
799
+ *
800
+ * Both lists are keyed by the Drizzle schema key, not the database name and not the generated
801
+ * GraphQL name.
802
+ */
803
+ type SchemaExclusions = {
804
+ /**
805
+ * Tables that generate nothing at all: no object type, no queries, no mutations, and no
806
+ * relation fields on other tables that point at them.
807
+ */
808
+ tables?: string[];
809
+ /** Per-table column exclusions, keyed by the table's key in the Drizzle schema. */
810
+ columns?: Record<string, string[]>;
811
+ };
797
812
  type BuildSchemaConfig = {
798
813
  /**
799
814
  * Determines whether generated mutations will be passed to returned schema.
@@ -982,6 +997,36 @@ type BuildSchemaConfig = {
982
997
  * agree.
983
998
  */
984
999
  limits?: LimitsConfig;
1000
+ /**
1001
+ * Tables and columns to leave out of the generated schema entirely.
1002
+ *
1003
+ * ```ts
1004
+ * buildSchema(db, {
1005
+ * exclude: {
1006
+ * tables: ['magicLinks', 'sessions'],
1007
+ * columns: { apiKeys: ['keyHash'] },
1008
+ * },
1009
+ * });
1010
+ * ```
1011
+ *
1012
+ * An excluded **table** generates nothing: no object type, no root queries or mutations, no
1013
+ * aggregates, and no relation field on any other table that points at it. Filtering another
1014
+ * table by a relation to it is gone too, so it is unreachable rather than merely unnamed.
1015
+ *
1016
+ * An excluded **column** disappears from every surface at once — the object type, the
1017
+ * create/update/upsert inputs, the filter type, `orderBy`, the aggregate fields, the
1018
+ * `distinct` and `groupBy` enums, and the upsert conflict targets. The exclusion is
1019
+ * deliberately all-or-nothing: a column you can filter on but not select is an oracle, since
1020
+ * `where: { keyHash: { eq: '…' } }` confirms a value without ever returning it.
1021
+ *
1022
+ * Excluding a `NOT NULL` column that has no default makes that table's inserts impossible to
1023
+ * satisfy — `buildSchema` warns on the console when it sees this, and still builds, since a
1024
+ * read-only table is a reasonable thing to want.
1025
+ *
1026
+ * Names that match nothing throw, so a renamed column fails the build instead of quietly
1027
+ * un-hiding itself.
1028
+ */
1029
+ exclude?: SchemaExclusions;
985
1030
  /**
986
1031
  * Optional mapper from table key to singular/plural name pair.
987
1032
  * When provided for a table, overrides the default (table key) naming for GraphQL type names,
@@ -1210,4 +1255,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
1210
1255
 
1211
1256
  declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
1212
1257
 
1213
- export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ColumnDeprecator, type ColumnDescriber, type ColumnDocInfo, type ColumnTypeMapper, type ColumnTypeMapperInfo, type ComplexityConfig, type DeleteResolver, type DeleteSingleResolver, type EnumNameInfo, type EnumNameMapper, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, GraphQLDecimalString, type InsertArrResolver, type InsertResolver, type LimitsConfig, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationDescriber, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaDocs, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableDescriber, type TableLimitPolicy, type TableNamedRelations, type UpdateManyArgs, type UpdateManyEntry, type UpdateManyResolver, type UpdateResolver, type UpdateSingleResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
1258
+ export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ColumnDeprecator, type ColumnDescriber, type ColumnDocInfo, type ColumnTypeMapper, type ColumnTypeMapperInfo, type ComplexityConfig, type DeleteResolver, type DeleteSingleResolver, type EnumNameInfo, type EnumNameMapper, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, GraphQLDecimalString, type InsertArrResolver, type InsertResolver, type LimitsConfig, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationDescriber, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaDocs, type SchemaExclusions, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableDescriber, type TableLimitPolicy, type TableNamedRelations, type UpdateManyArgs, type UpdateManyEntry, type UpdateManyResolver, type UpdateResolver, type UpdateSingleResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/index.ts
2
- import { is as is8 } from "drizzle-orm";
2
+ import { getColumns as getColumns6, is as is8, Table } from "drizzle-orm";
3
3
  import { MySqlDatabase } from "drizzle-orm/mysql-core";
4
4
  import { PgAsyncDatabase } from "drizzle-orm/pg-core";
5
5
  import { BaseSQLiteDatabase } from "drizzle-orm/sqlite-core";
@@ -1198,6 +1198,30 @@ var resolveLimitPolicy = (global, table) => {
1198
1198
  }
1199
1199
  return { defaultLimit, maxLimit, clampToMax: table?.clampToMax ?? global?.clampToMax ?? false };
1200
1200
  };
1201
+ var excludedColumnRegistry = /* @__PURE__ */ new WeakMap();
1202
+ var registerColumnExclusions = (tables, exclude) => {
1203
+ for (const [tableName, table] of Object.entries(tables)) {
1204
+ const hidden = exclude?.columns?.[tableName];
1205
+ if (hidden?.length) {
1206
+ excludedColumnRegistry.set(table, new Set(hidden));
1207
+ } else {
1208
+ excludedColumnRegistry.delete(table);
1209
+ }
1210
+ }
1211
+ };
1212
+ var hasExcludedColumns = (table) => excludedColumnRegistry.has(table);
1213
+ var excludedColumnsKey = (table) => {
1214
+ const hidden = excludedColumnRegistry.get(table);
1215
+ return hidden ? [...hidden].sort().join(",") : "";
1216
+ };
1217
+ var visibleColumns = (table) => {
1218
+ const columns = getColumns2(table);
1219
+ const hidden = excludedColumnRegistry.get(table);
1220
+ if (!hidden) {
1221
+ return columns;
1222
+ }
1223
+ return Object.fromEntries(Object.entries(columns).filter(([columnName]) => !hidden.has(columnName)));
1224
+ };
1201
1225
  var listFieldComplexity = (options, policy) => ({ args, childComplexity }) => {
1202
1226
  const limit = args["limit"];
1203
1227
  const requested = typeof limit === "number" && limit > 0 ? limit : void 0;
@@ -1507,17 +1531,20 @@ var generateColumnFilterValues = (column, tableName, columnName, cacheCtx) => {
1507
1531
  };
1508
1532
  var orderMap = /* @__PURE__ */ new WeakMap();
1509
1533
  var generateTableOrderCached = (table) => {
1510
- if (orderMap.has(table)) {
1534
+ const cacheable = !hasExcludedColumns(table);
1535
+ if (cacheable && orderMap.has(table)) {
1511
1536
  return orderMap.get(table);
1512
1537
  }
1513
1538
  let remapped = {};
1514
1539
  try {
1515
- const columns = getColumns2(table);
1540
+ const columns = visibleColumns(table);
1516
1541
  const columnEntries = Object.entries(columns);
1517
1542
  remapped = Object.fromEntries(
1518
1543
  columnEntries.map(([columnName, _columnDescription]) => [columnName, { type: innerOrder }])
1519
1544
  );
1520
- orderMap.set(table, remapped);
1545
+ if (cacheable) {
1546
+ orderMap.set(table, remapped);
1547
+ }
1521
1548
  } catch (_err) {
1522
1549
  }
1523
1550
  return remapped;
@@ -1526,7 +1553,7 @@ var generateTableFilterValuesCached = (table, tableName, cacheCtx) => {
1526
1553
  if (cacheCtx.filterFieldCache.has(table)) {
1527
1554
  return cacheCtx.filterFieldCache.get(table);
1528
1555
  }
1529
- const columns = getColumns2(table);
1556
+ const columns = visibleColumns(table);
1530
1557
  const columnEntries = Object.entries(columns);
1531
1558
  const remapped = Object.fromEntries(
1532
1559
  columnEntries.map(([columnName, column]) => [
@@ -1547,7 +1574,7 @@ var generateTableSelectTypeFieldsCached = (table, tableName, cacheCtx) => {
1547
1574
  if (cacheCtx.selectFieldCache.has(table)) {
1548
1575
  return cacheCtx.selectFieldCache.get(table);
1549
1576
  }
1550
- const columns = getColumns2(table);
1577
+ const columns = visibleColumns(table);
1551
1578
  const columnEntries = Object.entries(columns);
1552
1579
  const remapped = Object.fromEntries(
1553
1580
  columnEntries.map(([columnName, column]) => [
@@ -1905,7 +1932,7 @@ var generateTableTypes = (tableName, tables, relationMap, withReturning, relatio
1905
1932
  relationAggregateFactory
1906
1933
  );
1907
1934
  const table = tables[tableName];
1908
- const columns = getColumns2(table);
1935
+ const columns = visibleColumns(table);
1909
1936
  const columnEntries = Object.entries(columns);
1910
1937
  const relaxedColumns = nestedWrites?.relaxedColumns(tableName);
1911
1938
  const insertFields = Object.fromEntries(
@@ -2580,7 +2607,7 @@ var attachRowCursors = (rows, entries) => {
2580
2607
  };
2581
2608
  var rowCursorResolver = (source) => source?.[ROW_CURSOR_PROP] ?? null;
2582
2609
  var getUniqueColumnSets = (table, getTableConfig4) => {
2583
- const cols = getColumns2(table);
2610
+ const cols = visibleColumns(table);
2584
2611
  const propNameByColumnName = new Map(Object.entries(cols).map(([propName, col]) => [col.name, propName]));
2585
2612
  const toPropNames = (columnNames) => {
2586
2613
  const propNames = [];
@@ -2620,12 +2647,13 @@ var getUniqueColumnSets = (table, getTableConfig4) => {
2620
2647
  var DISTINCT_RN = "__drizzle_graphql_distinct_rn";
2621
2648
  var columnEnumCache = /* @__PURE__ */ new WeakMap();
2622
2649
  var generateColumnEnum = (table, enumName, description, predicate = () => true) => {
2650
+ const cacheKey = `${enumName}\0${excludedColumnsKey(table)}`;
2623
2651
  let tableCache = columnEnumCache.get(table);
2624
- const cached = tableCache?.get(enumName);
2652
+ const cached = tableCache?.get(cacheKey);
2625
2653
  if (cached) {
2626
2654
  return cached;
2627
2655
  }
2628
- const columnNames = Object.entries(getColumns2(table)).filter(([columnName, column]) => predicate(column, columnName)).map(([columnName]) => columnName);
2656
+ const columnNames = Object.entries(visibleColumns(table)).filter(([columnName, column]) => predicate(column, columnName)).map(([columnName]) => columnName);
2629
2657
  if (!columnNames.length) {
2630
2658
  return void 0;
2631
2659
  }
@@ -2638,7 +2666,7 @@ var generateColumnEnum = (table, enumName, description, predicate = () => true)
2638
2666
  tableCache = /* @__PURE__ */ new Map();
2639
2667
  columnEnumCache.set(table, tableCache);
2640
2668
  }
2641
- tableCache.set(enumName, enumType);
2669
+ tableCache.set(cacheKey, enumType);
2642
2670
  return enumType;
2643
2671
  };
2644
2672
  var generateDistinctEnum = (table, typeName) => generateColumnEnum(table, `${typeName}DistinctColumn`, `Columns of ${typeName} that a query can be made distinct on`);
@@ -3258,7 +3286,7 @@ var classifyAggregateColumns = (table, tableName) => {
3258
3286
  const numeric = {};
3259
3287
  const orderable = {};
3260
3288
  const all = {};
3261
- for (const [columnName, column] of Object.entries(getColumns3(table))) {
3289
+ for (const [columnName, column] of Object.entries(visibleColumns(table))) {
3262
3290
  all[columnName] = column;
3263
3291
  const converted = drizzleColumnToGraphQLType(column, columnName, tableName, true, false, false);
3264
3292
  const gqlType = converted.type;
@@ -3502,7 +3530,7 @@ var HAVING_OPS = { eq: eq2, ne: ne2, gt: gt2, gte: gte2, lt: lt2, lte: lte2 };
3502
3530
  var groupableColumns = (table, tableName) => {
3503
3531
  const { orderable } = classifyAggregateColumns(table, tableName);
3504
3532
  const groupable = { ...orderable };
3505
- for (const [columnName, column] of Object.entries(getColumns3(table))) {
3533
+ for (const [columnName, column] of Object.entries(visibleColumns(table))) {
3506
3534
  if (groupable[columnName]) {
3507
3535
  continue;
3508
3536
  }
@@ -3970,7 +3998,8 @@ var generateSchemaData = (db, schema, relations, options) => {
3970
3998
  const { relationsDepthLimit, prefixes, suffixes, typeNameMapper, shouldEagerLoad, features, complexity, limits } = options;
3971
3999
  const rawSchema = schema;
3972
4000
  const schemaEntries = Object.entries(rawSchema);
3973
- const tableEntries = schemaEntries.filter(([_key, value]) => is4(value, MySqlTable));
4001
+ const excludedTables = new Set(options.exclude?.tables ?? []);
4002
+ const tableEntries = schemaEntries.filter(([key, value]) => is4(value, MySqlTable) && !excludedTables.has(key));
3974
4003
  const tables = Object.fromEntries(tableEntries);
3975
4004
  if (!tableEntries.length) {
3976
4005
  throw new Error(
@@ -3984,7 +4013,11 @@ var generateSchemaData = (db, schema, relations, options) => {
3984
4013
  }
3985
4014
  registerScalarOverrides(tables, options);
3986
4015
  registerEnumConfig(options);
4016
+ registerColumnExclusions(tables, options.exclude);
3987
4017
  const namedRelations = buildNamedRelations(relations ?? {}, tableEntries);
4018
+ for (const excluded of excludedTables) {
4019
+ delete namedRelations[excluded];
4020
+ }
3988
4021
  attachTargetPrimaryKeys(namedRelations, tables, mysqlPrimaryKeyPropNames);
3989
4022
  const eagerRelations = pruneNonEagerRelations(namedRelations, shouldEagerLoad);
3990
4023
  const filterCtx = { tables, relationMap: namedRelations };
@@ -4463,7 +4496,7 @@ var createNestedWriteTypes = (params) => {
4463
4496
  }
4464
4497
  const omitted = plan.fkSide === "child" ? plan.foreignColPropName : void 0;
4465
4498
  const fields = Object.fromEntries(
4466
- Object.entries(getColumns4(plan.targetTable)).filter(([columnName]) => columnName !== omitted).map(([columnName, column]) => [
4499
+ Object.entries(visibleColumns(plan.targetTable)).filter(([columnName]) => columnName !== omitted).map(([columnName, column]) => [
4467
4500
  columnName,
4468
4501
  drizzleColumnToGraphQLType(column, columnName, plan.targetTableName, false, true, true)
4469
4502
  ])
@@ -5341,7 +5374,8 @@ function generateSchemaData2(db, schema, relations, options) {
5341
5374
  limits
5342
5375
  } = options;
5343
5376
  const schemaEntries = Object.entries(schema);
5344
- const tableEntries = schemaEntries.filter(([_key, value]) => is6(value, PgTable));
5377
+ const excludedTables = new Set(options.exclude?.tables ?? []);
5378
+ const tableEntries = schemaEntries.filter(([key, value]) => is6(value, PgTable) && !excludedTables.has(key));
5345
5379
  const tables = Object.fromEntries(tableEntries);
5346
5380
  if (!tableEntries.length) {
5347
5381
  throw new Error(
@@ -5350,7 +5384,11 @@ function generateSchemaData2(db, schema, relations, options) {
5350
5384
  }
5351
5385
  registerScalarOverrides(tables, options);
5352
5386
  registerEnumConfig(options);
5387
+ registerColumnExclusions(tables, options.exclude);
5353
5388
  const namedRelations = buildNamedRelations(relations ?? {}, tableEntries);
5389
+ for (const excluded of excludedTables) {
5390
+ delete namedRelations[excluded];
5391
+ }
5354
5392
  attachTargetPrimaryKeys(namedRelations, tables, pgPrimaryKeyPropNames);
5355
5393
  const eagerRelations = pruneNonEagerRelations(namedRelations, shouldEagerLoad);
5356
5394
  const filterCtx = { tables, relationMap: namedRelations };
@@ -6358,7 +6396,8 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6358
6396
  } = options;
6359
6397
  const rawSchema = schema;
6360
6398
  const schemaEntries = Object.entries(rawSchema);
6361
- const tableEntries = schemaEntries.filter(([_key, value]) => is7(value, SQLiteTable));
6399
+ const excludedTables = new Set(options.exclude?.tables ?? []);
6400
+ const tableEntries = schemaEntries.filter(([key, value]) => is7(value, SQLiteTable) && !excludedTables.has(key));
6362
6401
  const tables = Object.fromEntries(tableEntries);
6363
6402
  if (!tableEntries.length) {
6364
6403
  throw new Error(
@@ -6367,7 +6406,11 @@ var generateSchemaData3 = (db, schema, relations, options) => {
6367
6406
  }
6368
6407
  registerScalarOverrides(tables, options);
6369
6408
  registerEnumConfig(options);
6409
+ registerColumnExclusions(tables, options.exclude);
6370
6410
  const namedRelations = buildNamedRelations(relations ?? {}, tableEntries);
6411
+ for (const excluded of excludedTables) {
6412
+ delete namedRelations[excluded];
6413
+ }
6371
6414
  attachTargetPrimaryKeys(namedRelations, tables, sqlitePrimaryKeyPropNames);
6372
6415
  const eagerRelations = pruneNonEagerRelations(namedRelations, shouldEagerLoad);
6373
6416
  const filterCtx = { tables, relationMap: namedRelations };
@@ -6914,6 +6957,49 @@ var buildSchema = (db, config) => {
6914
6957
  limitPolicyCache.set(tableName, resolved);
6915
6958
  return resolved;
6916
6959
  } : void 0;
6960
+ const exclude = config?.exclude;
6961
+ if (exclude) {
6962
+ const tableNames = new Set(
6963
+ Object.entries(schema).filter(([, value]) => is8(value, Table)).map(([key]) => key)
6964
+ );
6965
+ const excludedTables = new Set(exclude.tables ?? []);
6966
+ for (const tableName of excludedTables) {
6967
+ if (!tableNames.has(tableName)) {
6968
+ throw new Error(
6969
+ `Drizzle-GraphQL Error: config.exclude.tables names '${tableName}', which is not a table in the Drizzle schema.`
6970
+ );
6971
+ }
6972
+ }
6973
+ if (excludedTables.size >= tableNames.size) {
6974
+ throw new Error(
6975
+ "Drizzle-GraphQL Error: config.exclude.tables excludes every table in the schema, leaving nothing to generate."
6976
+ );
6977
+ }
6978
+ for (const [tableName, columnNames] of Object.entries(exclude.columns ?? {})) {
6979
+ if (!tableNames.has(tableName)) {
6980
+ throw new Error(
6981
+ `Drizzle-GraphQL Error: config.exclude.columns names table '${tableName}', which is not a table in the Drizzle schema.`
6982
+ );
6983
+ }
6984
+ if (excludedTables.has(tableName)) {
6985
+ continue;
6986
+ }
6987
+ const columns = getColumns6(schema[tableName]);
6988
+ for (const columnName of columnNames) {
6989
+ const column = columns[columnName];
6990
+ if (!column) {
6991
+ throw new Error(
6992
+ `Drizzle-GraphQL Error: config.exclude.columns names '${tableName}.${columnName}', which is not a column of that table.`
6993
+ );
6994
+ }
6995
+ if (column.notNull && !column.hasDefault && !column.defaultFn) {
6996
+ console.warn(
6997
+ `Drizzle-GraphQL Warning: excluded column '${tableName}.${columnName}' is NOT NULL with no default, so generated inserts for '${tableName}' can never succeed.`
6998
+ );
6999
+ }
7000
+ }
7001
+ }
7002
+ }
6917
7003
  const eagerOpt = config?.eagerLoadRelations;
6918
7004
  const shouldEagerLoad = eagerOpt === void 0 || eagerOpt === true ? () => true : eagerOpt === false ? () => false : eagerOpt;
6919
7005
  if (!typeNameMapper && suffixes.list === suffixes.single) {
@@ -6947,6 +7033,7 @@ var buildSchema = (db, config) => {
6947
7033
  enumNameMapper: config?.enumNameMapper,
6948
7034
  transactions,
6949
7035
  limits,
7036
+ exclude,
6950
7037
  docs: {
6951
7038
  describeColumn: config?.describeColumn,
6952
7039
  describeTable: config?.describeTable,