@vantreeseba/drizzle-graphql 7.1.0 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -2
- package/dist/README.md +174 -2
- package/dist/index.cjs +317 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -2
- package/dist/index.d.ts +56 -2
- package/dist/index.js +318 -41
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -188,6 +188,12 @@ type OrderByArgs<TTable extends Table> = {
|
|
|
188
188
|
* emulated with an extra `IS NULL` sort key on MySQL.
|
|
189
189
|
*/
|
|
190
190
|
nulls?: 'first' | 'last';
|
|
191
|
+
/**
|
|
192
|
+
* Sort by the column's position in the `inArray` list the same request's `where` gives
|
|
193
|
+
* it, rather than by the column's own value. Requires that `inArray` filter; cannot be
|
|
194
|
+
* combined with `after` or `distinct`.
|
|
195
|
+
*/
|
|
196
|
+
matchFilterOrder?: boolean;
|
|
191
197
|
};
|
|
192
198
|
};
|
|
193
199
|
|
|
@@ -262,10 +268,13 @@ type LimitPolicyFor = (tableName: string) => ResolvedLimitPolicy | undefined;
|
|
|
262
268
|
* across relation boundaries. Each entry may also carry `nulls: first | last`
|
|
263
269
|
* (see {@link orderExpressions} for how MySQL emulates it).
|
|
264
270
|
*
|
|
271
|
+
* An entry may instead set `matchFilterOrder`, which sorts by the column's position in the
|
|
272
|
+
* `inArray` list the same request's `where` gives it — `whereArgs` is that `where`.
|
|
273
|
+
*
|
|
265
274
|
* `ctx` supplies the tables and relation map that relation ordering needs; callers whose
|
|
266
275
|
* inputs cannot contain relation keys may omit it.
|
|
267
276
|
*/
|
|
268
|
-
declare const extractOrderBy: <TTable extends Table, TArgs extends OrderByArgs<any> = OrderByArgs<TTable>>(table: TTable, orderArgs: TArgs, ctx?: RelationFilterContext) => SQL[];
|
|
277
|
+
declare const extractOrderBy: <TTable extends Table, TArgs extends OrderByArgs<any> = OrderByArgs<TTable>>(table: TTable, orderArgs: TArgs, ctx?: RelationFilterContext, whereArgs?: Record<string, any>) => SQL[];
|
|
269
278
|
/**
|
|
270
279
|
* Everything `extractFilters` needs to turn a relation key in a `where` argument into a
|
|
271
280
|
* correlated subquery. Omitted by callers that don't generate relation filters, in which case
|
|
@@ -794,6 +803,21 @@ type LimitsConfig = TableLimitPolicy & {
|
|
|
794
803
|
/** Per-table overrides, keyed by the table's key in the Drizzle schema. */
|
|
795
804
|
tables?: Record<string, TableLimitPolicy>;
|
|
796
805
|
};
|
|
806
|
+
/**
|
|
807
|
+
* {@link BuildSchemaConfig.exclude} — tables and columns to keep out of the generated schema.
|
|
808
|
+
*
|
|
809
|
+
* Both lists are keyed by the Drizzle schema key, not the database name and not the generated
|
|
810
|
+
* GraphQL name.
|
|
811
|
+
*/
|
|
812
|
+
type SchemaExclusions = {
|
|
813
|
+
/**
|
|
814
|
+
* Tables that generate nothing at all: no object type, no queries, no mutations, and no
|
|
815
|
+
* relation fields on other tables that point at them.
|
|
816
|
+
*/
|
|
817
|
+
tables?: string[];
|
|
818
|
+
/** Per-table column exclusions, keyed by the table's key in the Drizzle schema. */
|
|
819
|
+
columns?: Record<string, string[]>;
|
|
820
|
+
};
|
|
797
821
|
type BuildSchemaConfig = {
|
|
798
822
|
/**
|
|
799
823
|
* Determines whether generated mutations will be passed to returned schema.
|
|
@@ -982,6 +1006,36 @@ type BuildSchemaConfig = {
|
|
|
982
1006
|
* agree.
|
|
983
1007
|
*/
|
|
984
1008
|
limits?: LimitsConfig;
|
|
1009
|
+
/**
|
|
1010
|
+
* Tables and columns to leave out of the generated schema entirely.
|
|
1011
|
+
*
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* buildSchema(db, {
|
|
1014
|
+
* exclude: {
|
|
1015
|
+
* tables: ['magicLinks', 'sessions'],
|
|
1016
|
+
* columns: { apiKeys: ['keyHash'] },
|
|
1017
|
+
* },
|
|
1018
|
+
* });
|
|
1019
|
+
* ```
|
|
1020
|
+
*
|
|
1021
|
+
* An excluded **table** generates nothing: no object type, no root queries or mutations, no
|
|
1022
|
+
* aggregates, and no relation field on any other table that points at it. Filtering another
|
|
1023
|
+
* table by a relation to it is gone too, so it is unreachable rather than merely unnamed.
|
|
1024
|
+
*
|
|
1025
|
+
* An excluded **column** disappears from every surface at once — the object type, the
|
|
1026
|
+
* create/update/upsert inputs, the filter type, `orderBy`, the aggregate fields, the
|
|
1027
|
+
* `distinct` and `groupBy` enums, and the upsert conflict targets. The exclusion is
|
|
1028
|
+
* deliberately all-or-nothing: a column you can filter on but not select is an oracle, since
|
|
1029
|
+
* `where: { keyHash: { eq: '…' } }` confirms a value without ever returning it.
|
|
1030
|
+
*
|
|
1031
|
+
* Excluding a `NOT NULL` column that has no default makes that table's inserts impossible to
|
|
1032
|
+
* satisfy — `buildSchema` warns on the console when it sees this, and still builds, since a
|
|
1033
|
+
* read-only table is a reasonable thing to want.
|
|
1034
|
+
*
|
|
1035
|
+
* Names that match nothing throw, so a renamed column fails the build instead of quietly
|
|
1036
|
+
* un-hiding itself.
|
|
1037
|
+
*/
|
|
1038
|
+
exclude?: SchemaExclusions;
|
|
985
1039
|
/**
|
|
986
1040
|
* Optional mapper from table key to singular/plural name pair.
|
|
987
1041
|
* When provided for a table, overrides the default (table key) naming for GraphQL type names,
|
|
@@ -1210,4 +1264,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
1210
1264
|
|
|
1211
1265
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
1212
1266
|
|
|
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 };
|
|
1267
|
+
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
|
@@ -188,6 +188,12 @@ type OrderByArgs<TTable extends Table> = {
|
|
|
188
188
|
* emulated with an extra `IS NULL` sort key on MySQL.
|
|
189
189
|
*/
|
|
190
190
|
nulls?: 'first' | 'last';
|
|
191
|
+
/**
|
|
192
|
+
* Sort by the column's position in the `inArray` list the same request's `where` gives
|
|
193
|
+
* it, rather than by the column's own value. Requires that `inArray` filter; cannot be
|
|
194
|
+
* combined with `after` or `distinct`.
|
|
195
|
+
*/
|
|
196
|
+
matchFilterOrder?: boolean;
|
|
191
197
|
};
|
|
192
198
|
};
|
|
193
199
|
|
|
@@ -262,10 +268,13 @@ type LimitPolicyFor = (tableName: string) => ResolvedLimitPolicy | undefined;
|
|
|
262
268
|
* across relation boundaries. Each entry may also carry `nulls: first | last`
|
|
263
269
|
* (see {@link orderExpressions} for how MySQL emulates it).
|
|
264
270
|
*
|
|
271
|
+
* An entry may instead set `matchFilterOrder`, which sorts by the column's position in the
|
|
272
|
+
* `inArray` list the same request's `where` gives it — `whereArgs` is that `where`.
|
|
273
|
+
*
|
|
265
274
|
* `ctx` supplies the tables and relation map that relation ordering needs; callers whose
|
|
266
275
|
* inputs cannot contain relation keys may omit it.
|
|
267
276
|
*/
|
|
268
|
-
declare const extractOrderBy: <TTable extends Table, TArgs extends OrderByArgs<any> = OrderByArgs<TTable>>(table: TTable, orderArgs: TArgs, ctx?: RelationFilterContext) => SQL[];
|
|
277
|
+
declare const extractOrderBy: <TTable extends Table, TArgs extends OrderByArgs<any> = OrderByArgs<TTable>>(table: TTable, orderArgs: TArgs, ctx?: RelationFilterContext, whereArgs?: Record<string, any>) => SQL[];
|
|
269
278
|
/**
|
|
270
279
|
* Everything `extractFilters` needs to turn a relation key in a `where` argument into a
|
|
271
280
|
* correlated subquery. Omitted by callers that don't generate relation filters, in which case
|
|
@@ -794,6 +803,21 @@ type LimitsConfig = TableLimitPolicy & {
|
|
|
794
803
|
/** Per-table overrides, keyed by the table's key in the Drizzle schema. */
|
|
795
804
|
tables?: Record<string, TableLimitPolicy>;
|
|
796
805
|
};
|
|
806
|
+
/**
|
|
807
|
+
* {@link BuildSchemaConfig.exclude} — tables and columns to keep out of the generated schema.
|
|
808
|
+
*
|
|
809
|
+
* Both lists are keyed by the Drizzle schema key, not the database name and not the generated
|
|
810
|
+
* GraphQL name.
|
|
811
|
+
*/
|
|
812
|
+
type SchemaExclusions = {
|
|
813
|
+
/**
|
|
814
|
+
* Tables that generate nothing at all: no object type, no queries, no mutations, and no
|
|
815
|
+
* relation fields on other tables that point at them.
|
|
816
|
+
*/
|
|
817
|
+
tables?: string[];
|
|
818
|
+
/** Per-table column exclusions, keyed by the table's key in the Drizzle schema. */
|
|
819
|
+
columns?: Record<string, string[]>;
|
|
820
|
+
};
|
|
797
821
|
type BuildSchemaConfig = {
|
|
798
822
|
/**
|
|
799
823
|
* Determines whether generated mutations will be passed to returned schema.
|
|
@@ -982,6 +1006,36 @@ type BuildSchemaConfig = {
|
|
|
982
1006
|
* agree.
|
|
983
1007
|
*/
|
|
984
1008
|
limits?: LimitsConfig;
|
|
1009
|
+
/**
|
|
1010
|
+
* Tables and columns to leave out of the generated schema entirely.
|
|
1011
|
+
*
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* buildSchema(db, {
|
|
1014
|
+
* exclude: {
|
|
1015
|
+
* tables: ['magicLinks', 'sessions'],
|
|
1016
|
+
* columns: { apiKeys: ['keyHash'] },
|
|
1017
|
+
* },
|
|
1018
|
+
* });
|
|
1019
|
+
* ```
|
|
1020
|
+
*
|
|
1021
|
+
* An excluded **table** generates nothing: no object type, no root queries or mutations, no
|
|
1022
|
+
* aggregates, and no relation field on any other table that points at it. Filtering another
|
|
1023
|
+
* table by a relation to it is gone too, so it is unreachable rather than merely unnamed.
|
|
1024
|
+
*
|
|
1025
|
+
* An excluded **column** disappears from every surface at once — the object type, the
|
|
1026
|
+
* create/update/upsert inputs, the filter type, `orderBy`, the aggregate fields, the
|
|
1027
|
+
* `distinct` and `groupBy` enums, and the upsert conflict targets. The exclusion is
|
|
1028
|
+
* deliberately all-or-nothing: a column you can filter on but not select is an oracle, since
|
|
1029
|
+
* `where: { keyHash: { eq: '…' } }` confirms a value without ever returning it.
|
|
1030
|
+
*
|
|
1031
|
+
* Excluding a `NOT NULL` column that has no default makes that table's inserts impossible to
|
|
1032
|
+
* satisfy — `buildSchema` warns on the console when it sees this, and still builds, since a
|
|
1033
|
+
* read-only table is a reasonable thing to want.
|
|
1034
|
+
*
|
|
1035
|
+
* Names that match nothing throw, so a renamed column fails the build instead of quietly
|
|
1036
|
+
* un-hiding itself.
|
|
1037
|
+
*/
|
|
1038
|
+
exclude?: SchemaExclusions;
|
|
985
1039
|
/**
|
|
986
1040
|
* Optional mapper from table key to singular/plural name pair.
|
|
987
1041
|
* When provided for a table, overrides the default (table key) naming for GraphQL type names,
|
|
@@ -1210,4 +1264,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
1210
1264
|
|
|
1211
1265
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
1212
1266
|
|
|
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 };
|
|
1267
|
+
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 };
|