@vantreeseba/drizzle-graphql 7.3.0 → 7.4.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 +62 -0
- package/dist/README.md +62 -0
- package/dist/index.cjs +180 -103
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +91 -23
- package/dist/index.d.ts +91 -23
- package/dist/index.js +178 -102
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -632,27 +632,39 @@ type GeneratedData<TDatabase extends AnyDrizzleDB<any>> = {
|
|
|
632
632
|
entities: GeneratedEntities<TDatabase>;
|
|
633
633
|
};
|
|
634
634
|
/**
|
|
635
|
-
*
|
|
635
|
+
* A feature switch. `true` / `false` decides for the whole build; a predicate decides per
|
|
636
|
+
* table, receiving the table's key in the Drizzle schema.
|
|
637
|
+
*
|
|
638
|
+
* ```ts
|
|
639
|
+
* features: { delete: (table) => table !== 'auditLog' }
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
type FeatureSwitch = boolean | ((tableName: string) => boolean);
|
|
643
|
+
/**
|
|
644
|
+
* Per-feature switches for what `buildSchema` generates. Every flag defaults to `true` except
|
|
645
|
+
* `upsert`, `nestedWrites`, `fieldUpdateOperations`, `countMutations` and `requireWhere`.
|
|
646
|
+
* Each one takes a boolean or a per-table predicate, apart from `nestedWrites`, which is
|
|
647
|
+
* build-wide.
|
|
636
648
|
* See {@link BuildSchemaConfig.features}.
|
|
637
649
|
*/
|
|
638
650
|
type SchemaFeatures = {
|
|
639
651
|
/** `<plural>Aggregate` root queries and the aggregate output types. @default true */
|
|
640
|
-
aggregates?:
|
|
652
|
+
aggregates?: FeatureSwitch;
|
|
641
653
|
/**
|
|
642
654
|
* `<plural>GroupBy` root queries — the same aggregates, one row per group. Requires
|
|
643
655
|
* `aggregates`, whose output types the grouped result reuses.
|
|
644
656
|
*
|
|
645
657
|
* @default true
|
|
646
658
|
*/
|
|
647
|
-
groupBy?:
|
|
659
|
+
groupBy?: FeatureSwitch;
|
|
648
660
|
/** `<relation>Aggregate` fields on object types, for to-many relations. @default true */
|
|
649
|
-
relationAggregates?:
|
|
661
|
+
relationAggregates?: FeatureSwitch;
|
|
650
662
|
/** The `distinct` argument on list queries. @default true */
|
|
651
|
-
distinct?:
|
|
663
|
+
distinct?: FeatureSwitch;
|
|
652
664
|
/** `create<Table>` / `create<Table>Single` mutations. @default true */
|
|
653
|
-
insert?:
|
|
665
|
+
insert?: FeatureSwitch;
|
|
654
666
|
/** `update<Table>` / `update<Table>Single` mutations. @default true */
|
|
655
|
-
update?:
|
|
667
|
+
update?: FeatureSwitch;
|
|
656
668
|
/**
|
|
657
669
|
* `update<Table>Many` mutations — batch update with a per-entry `set` and `where`,
|
|
658
670
|
* executed inside one transaction. Only generated when `update` is also enabled,
|
|
@@ -660,9 +672,9 @@ type SchemaFeatures = {
|
|
|
660
672
|
*
|
|
661
673
|
* @default true
|
|
662
674
|
*/
|
|
663
|
-
updateMany?:
|
|
675
|
+
updateMany?: FeatureSwitch;
|
|
664
676
|
/** `delete<Table>` / `delete<Table>Single` mutations. @default true */
|
|
665
|
-
delete?:
|
|
677
|
+
delete?: FeatureSwitch;
|
|
666
678
|
/**
|
|
667
679
|
* `upsert<Table>` / `upsert<Table>Single` mutations — insert, or update the row that
|
|
668
680
|
* already holds the same unique key. Off unless asked for, so an existing schema does
|
|
@@ -670,7 +682,7 @@ type SchemaFeatures = {
|
|
|
670
682
|
*
|
|
671
683
|
* @default false
|
|
672
684
|
*/
|
|
673
|
-
upsert?:
|
|
685
|
+
upsert?: FeatureSwitch;
|
|
674
686
|
/**
|
|
675
687
|
* Relation fields on `Create<Table>Input` and `Update<Table>Input`, so a parent row and
|
|
676
688
|
* the rows it is related to can be written in one mutation. Off unless asked for: it adds
|
|
@@ -728,7 +740,7 @@ type SchemaFeatures = {
|
|
|
728
740
|
*
|
|
729
741
|
* @default false
|
|
730
742
|
*/
|
|
731
|
-
fieldUpdateOperations?:
|
|
743
|
+
fieldUpdateOperations?: FeatureSwitch;
|
|
732
744
|
/**
|
|
733
745
|
* `update<Table>Count` / `delete<Table>Count` mutations — the same write as the plural
|
|
734
746
|
* `update<Table>` / `delete<Table>`, returning the number of rows affected instead of the
|
|
@@ -747,7 +759,7 @@ type SchemaFeatures = {
|
|
|
747
759
|
*
|
|
748
760
|
* @default false
|
|
749
761
|
*/
|
|
750
|
-
countMutations?:
|
|
762
|
+
countMutations?: FeatureSwitch;
|
|
751
763
|
/**
|
|
752
764
|
* Makes `where` non-null on the plural `update<Table>` / `delete<Table>` mutations, and
|
|
753
765
|
* rejects a `where` that collapses to no filters (e.g. `where: {}`), so a schema can rule
|
|
@@ -758,7 +770,7 @@ type SchemaFeatures = {
|
|
|
758
770
|
*
|
|
759
771
|
* @default false
|
|
760
772
|
*/
|
|
761
|
-
requireWhere?:
|
|
773
|
+
requireWhere?: FeatureSwitch;
|
|
762
774
|
};
|
|
763
775
|
/**
|
|
764
776
|
* Per-field cost hints for `graphql-query-complexity` (or any estimator that reads
|
|
@@ -912,11 +924,11 @@ type BuildSchemaConfig = {
|
|
|
912
924
|
*/
|
|
913
925
|
complexity?: boolean | ComplexityConfig;
|
|
914
926
|
/**
|
|
915
|
-
* Turns individual generated features off.
|
|
927
|
+
* Turns individual generated features off, for the whole build or per table.
|
|
916
928
|
*
|
|
917
|
-
* Every flag defaults to `true` except `upsert`, which
|
|
918
|
-
* `features` block generates exactly what it generated before this option
|
|
919
|
-
* Turning one off removes both the schema surface it adds and the work behind it.
|
|
929
|
+
* Every flag defaults to `true` except `upsert` and `nestedWrites`, which are opt-in: a
|
|
930
|
+
* build with no `features` block generates exactly what it generated before this option
|
|
931
|
+
* existed. Turning one off removes both the schema surface it adds and the work behind it.
|
|
920
932
|
*
|
|
921
933
|
* ```ts
|
|
922
934
|
* buildSchema(db, {
|
|
@@ -930,9 +942,34 @@ type BuildSchemaConfig = {
|
|
|
930
942
|
* });
|
|
931
943
|
* ```
|
|
932
944
|
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
945
|
+
* Any flag may instead be a predicate, which is asked once per table with the table's key
|
|
946
|
+
* in the Drizzle schema — the usual case, where a handful of tables must not be written
|
|
947
|
+
* through the API and the rest want the full set:
|
|
948
|
+
*
|
|
949
|
+
* ```ts
|
|
950
|
+
* buildSchema(db, {
|
|
951
|
+
* features: {
|
|
952
|
+
* delete: (table) => table !== 'auditLog',
|
|
953
|
+
* update: (table) => !ownedByCustomResolver.has(table),
|
|
954
|
+
* upsert: (table) => table === 'settings',
|
|
955
|
+
* },
|
|
956
|
+
* });
|
|
957
|
+
* ```
|
|
958
|
+
*
|
|
959
|
+
* A table that generates nothing at all belongs in {@link BuildSchemaConfig.exclude}; this
|
|
960
|
+
* decides which operations a table that *is* in the schema offers. `nestedWrites` is the one
|
|
961
|
+
* flag that stays build-wide: its plans are computed once over the whole relation graph, and
|
|
962
|
+
* a nested write reaches a second table by definition.
|
|
963
|
+
*
|
|
964
|
+
* Some operations are built out of others — an upsert writes through insert and update, a
|
|
965
|
+
* batch update reuses the update input, a grouped query reuses the aggregate types. Flags
|
|
966
|
+
* that contradict those implications warn on the console at build time (naming the tables)
|
|
967
|
+
* rather than leaving a second write path past the operation you turned off to be found
|
|
968
|
+
* later.
|
|
969
|
+
*
|
|
970
|
+
* Turning off every mutation feature for every table omits the `Mutation` type entirely,
|
|
971
|
+
* exactly as `mutations: false` does. Query-side features can all be off — the list and
|
|
972
|
+
* single queries are always generated, so `Query` is never empty.
|
|
936
973
|
*/
|
|
937
974
|
features?: SchemaFeatures;
|
|
938
975
|
/**
|
|
@@ -1045,11 +1082,23 @@ type BuildSchemaConfig = {
|
|
|
1045
1082
|
* Example: `(name) => name === 'users' ? { singular: 'user', plural: 'users' } : undefined`
|
|
1046
1083
|
* produces type `User`, queries `users` / `user`, mutations `createUsers` / `createUser` for
|
|
1047
1084
|
* the `users` table, and leaves other tables with their default names.
|
|
1085
|
+
*
|
|
1086
|
+
* Pass the string `'singularize'` for the built-in preset, which derives both forms of every
|
|
1087
|
+
* table key with the library's own `pluralize` — the mapper most schemas with plural table
|
|
1088
|
+
* keys would otherwise write by hand:
|
|
1089
|
+
*
|
|
1090
|
+
* ```ts
|
|
1091
|
+
* buildSchema(db, { typeNameMapper: 'singularize' });
|
|
1092
|
+
* // tasks -> type Task, queries `tasks` / `task`, mutations `createTasks` / `createTask`
|
|
1093
|
+
* ```
|
|
1094
|
+
*
|
|
1095
|
+
* The same function is exported as `singularizeMapper` for wrapping — e.g. to keep one
|
|
1096
|
+
* table's names as they are: `(t) => (t === 'audit_log' ? undefined : singularizeMapper(t))`.
|
|
1048
1097
|
*/
|
|
1049
|
-
typeNameMapper?: (tableName: string) => {
|
|
1098
|
+
typeNameMapper?: 'singularize' | ((tableName: string) => {
|
|
1050
1099
|
singular: string;
|
|
1051
1100
|
plural: string;
|
|
1052
|
-
} | undefined;
|
|
1101
|
+
} | undefined);
|
|
1053
1102
|
/**
|
|
1054
1103
|
* Controls whether a relation is eagerly pre-fetched via Drizzle's `with:` clause
|
|
1055
1104
|
* when its parent is loaded through a generated query or mutation.
|
|
@@ -1247,6 +1296,25 @@ type BuildSchemaConfig = {
|
|
|
1247
1296
|
enumNameMapper?: EnumNameMapper;
|
|
1248
1297
|
};
|
|
1249
1298
|
|
|
1299
|
+
/**
|
|
1300
|
+
* The `typeNameMapper` preset behind `typeNameMapper: 'singularize'`.
|
|
1301
|
+
*
|
|
1302
|
+
* Derives the singular and plural forms of a table key with the library's own `pluralize`,
|
|
1303
|
+
* which is what nearly every consumer with plural table keys (`export const tasks =
|
|
1304
|
+
* pgTable('tasks', …)`) was writing by hand — and adding `pluralize` to their own
|
|
1305
|
+
* dependencies to write.
|
|
1306
|
+
*
|
|
1307
|
+
* `tasks` becomes type `Task`, queries `tasks` / `task`, mutations `createTasks` /
|
|
1308
|
+
* `createTask`. A key that is already singular is pluralized for the list side, so `task`
|
|
1309
|
+
* yields the same names, and a capitalized key (`Tasks`) yields them too — the field forms
|
|
1310
|
+
* are uncapitalized so the generated names follow GraphQL's camelCase convention whatever
|
|
1311
|
+
* the schema key looks like. The type name is capitalized by the generator either way.
|
|
1312
|
+
*/
|
|
1313
|
+
declare const singularizeMapper: (tableName: string) => {
|
|
1314
|
+
singular: string;
|
|
1315
|
+
plural: string;
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1250
1318
|
/**
|
|
1251
1319
|
* A 64-bit integer. Always transported as a decimal string, in both directions, so no value
|
|
1252
1320
|
* is ever silently rounded by JSON's double-precision numbers. `graphql-scalars`' own
|
|
@@ -1264,4 +1332,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
1264
1332
|
|
|
1265
1333
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
1266
1334
|
|
|
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 };
|
|
1335
|
+
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 FeatureSwitch, 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, singularizeMapper };
|
package/dist/index.d.ts
CHANGED
|
@@ -632,27 +632,39 @@ type GeneratedData<TDatabase extends AnyDrizzleDB<any>> = {
|
|
|
632
632
|
entities: GeneratedEntities<TDatabase>;
|
|
633
633
|
};
|
|
634
634
|
/**
|
|
635
|
-
*
|
|
635
|
+
* A feature switch. `true` / `false` decides for the whole build; a predicate decides per
|
|
636
|
+
* table, receiving the table's key in the Drizzle schema.
|
|
637
|
+
*
|
|
638
|
+
* ```ts
|
|
639
|
+
* features: { delete: (table) => table !== 'auditLog' }
|
|
640
|
+
* ```
|
|
641
|
+
*/
|
|
642
|
+
type FeatureSwitch = boolean | ((tableName: string) => boolean);
|
|
643
|
+
/**
|
|
644
|
+
* Per-feature switches for what `buildSchema` generates. Every flag defaults to `true` except
|
|
645
|
+
* `upsert`, `nestedWrites`, `fieldUpdateOperations`, `countMutations` and `requireWhere`.
|
|
646
|
+
* Each one takes a boolean or a per-table predicate, apart from `nestedWrites`, which is
|
|
647
|
+
* build-wide.
|
|
636
648
|
* See {@link BuildSchemaConfig.features}.
|
|
637
649
|
*/
|
|
638
650
|
type SchemaFeatures = {
|
|
639
651
|
/** `<plural>Aggregate` root queries and the aggregate output types. @default true */
|
|
640
|
-
aggregates?:
|
|
652
|
+
aggregates?: FeatureSwitch;
|
|
641
653
|
/**
|
|
642
654
|
* `<plural>GroupBy` root queries — the same aggregates, one row per group. Requires
|
|
643
655
|
* `aggregates`, whose output types the grouped result reuses.
|
|
644
656
|
*
|
|
645
657
|
* @default true
|
|
646
658
|
*/
|
|
647
|
-
groupBy?:
|
|
659
|
+
groupBy?: FeatureSwitch;
|
|
648
660
|
/** `<relation>Aggregate` fields on object types, for to-many relations. @default true */
|
|
649
|
-
relationAggregates?:
|
|
661
|
+
relationAggregates?: FeatureSwitch;
|
|
650
662
|
/** The `distinct` argument on list queries. @default true */
|
|
651
|
-
distinct?:
|
|
663
|
+
distinct?: FeatureSwitch;
|
|
652
664
|
/** `create<Table>` / `create<Table>Single` mutations. @default true */
|
|
653
|
-
insert?:
|
|
665
|
+
insert?: FeatureSwitch;
|
|
654
666
|
/** `update<Table>` / `update<Table>Single` mutations. @default true */
|
|
655
|
-
update?:
|
|
667
|
+
update?: FeatureSwitch;
|
|
656
668
|
/**
|
|
657
669
|
* `update<Table>Many` mutations — batch update with a per-entry `set` and `where`,
|
|
658
670
|
* executed inside one transaction. Only generated when `update` is also enabled,
|
|
@@ -660,9 +672,9 @@ type SchemaFeatures = {
|
|
|
660
672
|
*
|
|
661
673
|
* @default true
|
|
662
674
|
*/
|
|
663
|
-
updateMany?:
|
|
675
|
+
updateMany?: FeatureSwitch;
|
|
664
676
|
/** `delete<Table>` / `delete<Table>Single` mutations. @default true */
|
|
665
|
-
delete?:
|
|
677
|
+
delete?: FeatureSwitch;
|
|
666
678
|
/**
|
|
667
679
|
* `upsert<Table>` / `upsert<Table>Single` mutations — insert, or update the row that
|
|
668
680
|
* already holds the same unique key. Off unless asked for, so an existing schema does
|
|
@@ -670,7 +682,7 @@ type SchemaFeatures = {
|
|
|
670
682
|
*
|
|
671
683
|
* @default false
|
|
672
684
|
*/
|
|
673
|
-
upsert?:
|
|
685
|
+
upsert?: FeatureSwitch;
|
|
674
686
|
/**
|
|
675
687
|
* Relation fields on `Create<Table>Input` and `Update<Table>Input`, so a parent row and
|
|
676
688
|
* the rows it is related to can be written in one mutation. Off unless asked for: it adds
|
|
@@ -728,7 +740,7 @@ type SchemaFeatures = {
|
|
|
728
740
|
*
|
|
729
741
|
* @default false
|
|
730
742
|
*/
|
|
731
|
-
fieldUpdateOperations?:
|
|
743
|
+
fieldUpdateOperations?: FeatureSwitch;
|
|
732
744
|
/**
|
|
733
745
|
* `update<Table>Count` / `delete<Table>Count` mutations — the same write as the plural
|
|
734
746
|
* `update<Table>` / `delete<Table>`, returning the number of rows affected instead of the
|
|
@@ -747,7 +759,7 @@ type SchemaFeatures = {
|
|
|
747
759
|
*
|
|
748
760
|
* @default false
|
|
749
761
|
*/
|
|
750
|
-
countMutations?:
|
|
762
|
+
countMutations?: FeatureSwitch;
|
|
751
763
|
/**
|
|
752
764
|
* Makes `where` non-null on the plural `update<Table>` / `delete<Table>` mutations, and
|
|
753
765
|
* rejects a `where` that collapses to no filters (e.g. `where: {}`), so a schema can rule
|
|
@@ -758,7 +770,7 @@ type SchemaFeatures = {
|
|
|
758
770
|
*
|
|
759
771
|
* @default false
|
|
760
772
|
*/
|
|
761
|
-
requireWhere?:
|
|
773
|
+
requireWhere?: FeatureSwitch;
|
|
762
774
|
};
|
|
763
775
|
/**
|
|
764
776
|
* Per-field cost hints for `graphql-query-complexity` (or any estimator that reads
|
|
@@ -912,11 +924,11 @@ type BuildSchemaConfig = {
|
|
|
912
924
|
*/
|
|
913
925
|
complexity?: boolean | ComplexityConfig;
|
|
914
926
|
/**
|
|
915
|
-
* Turns individual generated features off.
|
|
927
|
+
* Turns individual generated features off, for the whole build or per table.
|
|
916
928
|
*
|
|
917
|
-
* Every flag defaults to `true` except `upsert`, which
|
|
918
|
-
* `features` block generates exactly what it generated before this option
|
|
919
|
-
* Turning one off removes both the schema surface it adds and the work behind it.
|
|
929
|
+
* Every flag defaults to `true` except `upsert` and `nestedWrites`, which are opt-in: a
|
|
930
|
+
* build with no `features` block generates exactly what it generated before this option
|
|
931
|
+
* existed. Turning one off removes both the schema surface it adds and the work behind it.
|
|
920
932
|
*
|
|
921
933
|
* ```ts
|
|
922
934
|
* buildSchema(db, {
|
|
@@ -930,9 +942,34 @@ type BuildSchemaConfig = {
|
|
|
930
942
|
* });
|
|
931
943
|
* ```
|
|
932
944
|
*
|
|
933
|
-
*
|
|
934
|
-
*
|
|
935
|
-
*
|
|
945
|
+
* Any flag may instead be a predicate, which is asked once per table with the table's key
|
|
946
|
+
* in the Drizzle schema — the usual case, where a handful of tables must not be written
|
|
947
|
+
* through the API and the rest want the full set:
|
|
948
|
+
*
|
|
949
|
+
* ```ts
|
|
950
|
+
* buildSchema(db, {
|
|
951
|
+
* features: {
|
|
952
|
+
* delete: (table) => table !== 'auditLog',
|
|
953
|
+
* update: (table) => !ownedByCustomResolver.has(table),
|
|
954
|
+
* upsert: (table) => table === 'settings',
|
|
955
|
+
* },
|
|
956
|
+
* });
|
|
957
|
+
* ```
|
|
958
|
+
*
|
|
959
|
+
* A table that generates nothing at all belongs in {@link BuildSchemaConfig.exclude}; this
|
|
960
|
+
* decides which operations a table that *is* in the schema offers. `nestedWrites` is the one
|
|
961
|
+
* flag that stays build-wide: its plans are computed once over the whole relation graph, and
|
|
962
|
+
* a nested write reaches a second table by definition.
|
|
963
|
+
*
|
|
964
|
+
* Some operations are built out of others — an upsert writes through insert and update, a
|
|
965
|
+
* batch update reuses the update input, a grouped query reuses the aggregate types. Flags
|
|
966
|
+
* that contradict those implications warn on the console at build time (naming the tables)
|
|
967
|
+
* rather than leaving a second write path past the operation you turned off to be found
|
|
968
|
+
* later.
|
|
969
|
+
*
|
|
970
|
+
* Turning off every mutation feature for every table omits the `Mutation` type entirely,
|
|
971
|
+
* exactly as `mutations: false` does. Query-side features can all be off — the list and
|
|
972
|
+
* single queries are always generated, so `Query` is never empty.
|
|
936
973
|
*/
|
|
937
974
|
features?: SchemaFeatures;
|
|
938
975
|
/**
|
|
@@ -1045,11 +1082,23 @@ type BuildSchemaConfig = {
|
|
|
1045
1082
|
* Example: `(name) => name === 'users' ? { singular: 'user', plural: 'users' } : undefined`
|
|
1046
1083
|
* produces type `User`, queries `users` / `user`, mutations `createUsers` / `createUser` for
|
|
1047
1084
|
* the `users` table, and leaves other tables with their default names.
|
|
1085
|
+
*
|
|
1086
|
+
* Pass the string `'singularize'` for the built-in preset, which derives both forms of every
|
|
1087
|
+
* table key with the library's own `pluralize` — the mapper most schemas with plural table
|
|
1088
|
+
* keys would otherwise write by hand:
|
|
1089
|
+
*
|
|
1090
|
+
* ```ts
|
|
1091
|
+
* buildSchema(db, { typeNameMapper: 'singularize' });
|
|
1092
|
+
* // tasks -> type Task, queries `tasks` / `task`, mutations `createTasks` / `createTask`
|
|
1093
|
+
* ```
|
|
1094
|
+
*
|
|
1095
|
+
* The same function is exported as `singularizeMapper` for wrapping — e.g. to keep one
|
|
1096
|
+
* table's names as they are: `(t) => (t === 'audit_log' ? undefined : singularizeMapper(t))`.
|
|
1048
1097
|
*/
|
|
1049
|
-
typeNameMapper?: (tableName: string) => {
|
|
1098
|
+
typeNameMapper?: 'singularize' | ((tableName: string) => {
|
|
1050
1099
|
singular: string;
|
|
1051
1100
|
plural: string;
|
|
1052
|
-
} | undefined;
|
|
1101
|
+
} | undefined);
|
|
1053
1102
|
/**
|
|
1054
1103
|
* Controls whether a relation is eagerly pre-fetched via Drizzle's `with:` clause
|
|
1055
1104
|
* when its parent is loaded through a generated query or mutation.
|
|
@@ -1247,6 +1296,25 @@ type BuildSchemaConfig = {
|
|
|
1247
1296
|
enumNameMapper?: EnumNameMapper;
|
|
1248
1297
|
};
|
|
1249
1298
|
|
|
1299
|
+
/**
|
|
1300
|
+
* The `typeNameMapper` preset behind `typeNameMapper: 'singularize'`.
|
|
1301
|
+
*
|
|
1302
|
+
* Derives the singular and plural forms of a table key with the library's own `pluralize`,
|
|
1303
|
+
* which is what nearly every consumer with plural table keys (`export const tasks =
|
|
1304
|
+
* pgTable('tasks', …)`) was writing by hand — and adding `pluralize` to their own
|
|
1305
|
+
* dependencies to write.
|
|
1306
|
+
*
|
|
1307
|
+
* `tasks` becomes type `Task`, queries `tasks` / `task`, mutations `createTasks` /
|
|
1308
|
+
* `createTask`. A key that is already singular is pluralized for the list side, so `task`
|
|
1309
|
+
* yields the same names, and a capitalized key (`Tasks`) yields them too — the field forms
|
|
1310
|
+
* are uncapitalized so the generated names follow GraphQL's camelCase convention whatever
|
|
1311
|
+
* the schema key looks like. The type name is capitalized by the generator either way.
|
|
1312
|
+
*/
|
|
1313
|
+
declare const singularizeMapper: (tableName: string) => {
|
|
1314
|
+
singular: string;
|
|
1315
|
+
plural: string;
|
|
1316
|
+
};
|
|
1317
|
+
|
|
1250
1318
|
/**
|
|
1251
1319
|
* A 64-bit integer. Always transported as a decimal string, in both directions, so no value
|
|
1252
1320
|
* is ever silently rounded by JSON's double-precision numbers. `graphql-scalars`' own
|
|
@@ -1264,4 +1332,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
1264
1332
|
|
|
1265
1333
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
1266
1334
|
|
|
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 };
|
|
1335
|
+
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 FeatureSwitch, 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, singularizeMapper };
|