@vantreeseba/drizzle-graphql 5.6.0 → 6.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/README.md +913 -768
- package/dist/README.md +913 -768
- package/dist/index.cjs +919 -250
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -1
- package/dist/index.d.ts +178 -1
- package/dist/index.js +923 -248
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -40,6 +40,63 @@ type ColumnTypeMapperInfo = {
|
|
|
40
40
|
* the built-in detection.
|
|
41
41
|
*/
|
|
42
42
|
type ColumnTypeMapper = (column: Column, info: ColumnTypeMapperInfo) => ScalarOverride | undefined;
|
|
43
|
+
/** Everything an {@link EnumNameMapper} needs to name — or opt a column out of — a generated enum type. */
|
|
44
|
+
type EnumNameInfo = {
|
|
45
|
+
/**
|
|
46
|
+
* The name the enum type was declared with (`pgEnum('status', …)`), shared by every column
|
|
47
|
+
* that uses it. `undefined` for an inline value list (`text({ enum: [...] })`,
|
|
48
|
+
* `mysqlEnum(...)`), which belongs to the one column that declares it.
|
|
49
|
+
*/
|
|
50
|
+
enumName: string | undefined;
|
|
51
|
+
/** The Postgres schema the named enum was declared in, when it declares one. */
|
|
52
|
+
schema: string | undefined;
|
|
53
|
+
/** The table's key in the Drizzle schema object. */
|
|
54
|
+
tableName: string;
|
|
55
|
+
/** The column's property name on the table object. */
|
|
56
|
+
columnName: string;
|
|
57
|
+
/** The enum's values, in declaration order. */
|
|
58
|
+
values: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Names a generated GraphQL enum type. Return `undefined` to keep the default name. See
|
|
62
|
+
* `BuildSchemaConfig.enumNameMapper`.
|
|
63
|
+
*/
|
|
64
|
+
type EnumNameMapper = (info: EnumNameInfo) => string | undefined;
|
|
65
|
+
/** Context handed to the documentation and deprecation hooks alongside the column itself. */
|
|
66
|
+
type ColumnDocInfo = {
|
|
67
|
+
/** The table's key in the Drizzle schema object. */
|
|
68
|
+
tableName: string;
|
|
69
|
+
/** The column's property name on the table object. */
|
|
70
|
+
columnName: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Supplies the GraphQL `description` for a generated column field. See
|
|
74
|
+
* `BuildSchemaConfig.describeColumn`.
|
|
75
|
+
*/
|
|
76
|
+
type ColumnDescriber = (column: Column, info: ColumnDocInfo) => string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Supplies the GraphQL `deprecationReason` for a generated column field. See
|
|
79
|
+
* `BuildSchemaConfig.deprecateColumn`.
|
|
80
|
+
*/
|
|
81
|
+
type ColumnDeprecator = (column: Column, info: ColumnDocInfo) => string | undefined;
|
|
82
|
+
/** Supplies the GraphQL `description` for a table's object type. See `BuildSchemaConfig.describeTable`. */
|
|
83
|
+
type TableDescriber = (tableName: string) => string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Supplies the GraphQL `description` for a relation field. See
|
|
86
|
+
* `BuildSchemaConfig.describeRelation`.
|
|
87
|
+
*/
|
|
88
|
+
type RelationDescriber = (tableName: string, relationName: string) => string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* The documentation hooks a build was configured with, resolved once and threaded through
|
|
91
|
+
* type generation. Every member is optional; a build with no hooks generates fields with no
|
|
92
|
+
* descriptions at all.
|
|
93
|
+
*/
|
|
94
|
+
type SchemaDocs = {
|
|
95
|
+
describeColumn?: ColumnDescriber;
|
|
96
|
+
describeTable?: TableDescriber;
|
|
97
|
+
describeRelation?: RelationDescriber;
|
|
98
|
+
deprecateColumn?: ColumnDeprecator;
|
|
99
|
+
};
|
|
43
100
|
|
|
44
101
|
type TableNamedRelations = {
|
|
45
102
|
relation: Relation;
|
|
@@ -580,6 +637,38 @@ type SchemaFeatures = {
|
|
|
580
637
|
* @default false
|
|
581
638
|
*/
|
|
582
639
|
upsert?: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Relation fields on `Create<Table>Input` and `Update<Table>Input`, so a parent row and
|
|
642
|
+
* the rows it is related to can be written in one mutation. Off unless asked for: it adds
|
|
643
|
+
* a field per writable relation to every create and update input.
|
|
644
|
+
*
|
|
645
|
+
* ```graphql
|
|
646
|
+
* createPostsSingle(values: {
|
|
647
|
+
* title: "Hello"
|
|
648
|
+
* author: { connect: { id: { eq: "a1" } } }
|
|
649
|
+
* tags: { create: [{ name: "drizzle" }] }
|
|
650
|
+
* }) { id }
|
|
651
|
+
* ```
|
|
652
|
+
*
|
|
653
|
+
* Each relation field offers `create` and `connect`; the update input adds `disconnect`
|
|
654
|
+
* and, for a to-many relation, `set` (replace the whole set). `disconnect` and `set` are
|
|
655
|
+
* generated only when the foreign key is nullable — there is no way to detach a row whose
|
|
656
|
+
* key is NOT NULL — and many-to-many (`.through()`) relations are not written through at
|
|
657
|
+
* all. Nesting is one level deep: the row a nested `create` inserts takes columns only.
|
|
658
|
+
*
|
|
659
|
+
* The whole tree runs in one transaction (a savepoint when the request already carries
|
|
660
|
+
* one), and a column a relation fills in (`authorId`, when `author: { create: … }` is
|
|
661
|
+
* offered) becomes nullable on the create input, since the relation is the other way to
|
|
662
|
+
* supply it.
|
|
663
|
+
*
|
|
664
|
+
* PostgreSQL and SQLite only. MySQL cannot return the rows it just wrote, which is how a
|
|
665
|
+
* nested write learns the parent's key, so `buildSchema` rejects the flag there. On SQLite
|
|
666
|
+
* the driver must be asynchronous (libsql, D1, …): a synchronous one commits before an
|
|
667
|
+
* awaited statement runs, so `buildSchema` rejects the combination outright.
|
|
668
|
+
*
|
|
669
|
+
* @default false
|
|
670
|
+
*/
|
|
671
|
+
nestedWrites?: boolean;
|
|
583
672
|
/**
|
|
584
673
|
* Makes `where` non-null on the plural `update<Table>` / `delete<Table>` mutations, and
|
|
585
674
|
* rejects a `where` that collapses to no filters (e.g. `where: {}`), so a schema can rule
|
|
@@ -884,6 +973,94 @@ type BuildSchemaConfig = {
|
|
|
884
973
|
* ```
|
|
885
974
|
*/
|
|
886
975
|
onError?: (error: unknown) => unknown;
|
|
976
|
+
/**
|
|
977
|
+
* Supplies the GraphQL `description` for a column, everywhere that column becomes a field:
|
|
978
|
+
* the object type, the create/update inputs, the filter input, and the aggregate
|
|
979
|
+
* `min`/`max`/`group` fields.
|
|
980
|
+
*
|
|
981
|
+
* Nothing is generated by default. The library used to emit the column's own type name
|
|
982
|
+
* ("DateTime", "JSON") as its description, which documented nothing a reader could not see
|
|
983
|
+
* from the type — that is gone, and this hook is what puts real prose in its place. Drizzle
|
|
984
|
+
* carries no column-comment metadata to read, so the text has to come from here.
|
|
985
|
+
*
|
|
986
|
+
* ```ts
|
|
987
|
+
* const columnDocs = { Users: { email: 'Primary contact address. Unique, case-insensitive.' } };
|
|
988
|
+
*
|
|
989
|
+
* buildSchema(db, {
|
|
990
|
+
* describeColumn: (_column, { tableName, columnName }) => columnDocs[tableName]?.[columnName],
|
|
991
|
+
* });
|
|
992
|
+
* ```
|
|
993
|
+
*
|
|
994
|
+
* `tableName` and `columnName` are the Drizzle schema keys. Return `undefined` to leave the
|
|
995
|
+
* field undocumented.
|
|
996
|
+
*/
|
|
997
|
+
describeColumn?: ColumnDescriber;
|
|
998
|
+
/**
|
|
999
|
+
* Supplies the GraphQL `description` for a table's object type.
|
|
1000
|
+
*
|
|
1001
|
+
* ```ts
|
|
1002
|
+
* buildSchema(db, { describeTable: (tableName) => tableDocs[tableName] });
|
|
1003
|
+
* ```
|
|
1004
|
+
*/
|
|
1005
|
+
describeTable?: TableDescriber;
|
|
1006
|
+
/**
|
|
1007
|
+
* Supplies the GraphQL `description` for a relation field on a table's object type.
|
|
1008
|
+
*
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* buildSchema(db, {
|
|
1011
|
+
* describeRelation: (tableName, relationName) =>
|
|
1012
|
+
* tableName === 'Users' && relationName === 'posts' ? 'Posts this user authored.' : undefined,
|
|
1013
|
+
* });
|
|
1014
|
+
* ```
|
|
1015
|
+
*
|
|
1016
|
+
* The generated `<relation>Aggregate` companion fields are not covered — they are derived
|
|
1017
|
+
* fields rather than the relation itself.
|
|
1018
|
+
*/
|
|
1019
|
+
describeRelation?: RelationDescriber;
|
|
1020
|
+
/**
|
|
1021
|
+
* Supplies the GraphQL `deprecationReason` for a column, marking it `@deprecated` on the
|
|
1022
|
+
* object type and on the create/update inputs.
|
|
1023
|
+
*
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* buildSchema(db, {
|
|
1026
|
+
* deprecateColumn: (_column, { columnName }) =>
|
|
1027
|
+
* columnName === 'legacyFlag' ? 'Use `status` instead.' : undefined,
|
|
1028
|
+
* });
|
|
1029
|
+
* ```
|
|
1030
|
+
*
|
|
1031
|
+
* A required input field cannot be deprecated — GraphQL rejects the schema, since a client
|
|
1032
|
+
* has no way to stop sending it — so the reason is dropped on non-null input fields and
|
|
1033
|
+
* kept everywhere else. Filter and orderBy fields are never deprecated either: filtering on
|
|
1034
|
+
* a deprecated column is how a caller finds the rows that still use it.
|
|
1035
|
+
*/
|
|
1036
|
+
deprecateColumn?: ColumnDeprecator;
|
|
1037
|
+
/**
|
|
1038
|
+
* Names the GraphQL enum types generated for enum columns.
|
|
1039
|
+
*
|
|
1040
|
+
* By default a column declared with a named `pgEnum` gets one shared type named after the
|
|
1041
|
+
* enum (`pgEnum('status', …)` → `StatusEnum`), reused by every column declared with that
|
|
1042
|
+
* same `pgEnum` — the database column is the same type, so a client variable typed
|
|
1043
|
+
* `StatusEnum!` is passable to any of them. A column with an inline value list
|
|
1044
|
+
* (`text({ enum: [...] })`, `mysqlEnum(...)`) keeps a per-column type named for its table
|
|
1045
|
+
* and column (`UsersRoleTextEnum`), because its values are shared with nothing.
|
|
1046
|
+
*
|
|
1047
|
+
* This hook overrides the name either way — for lining the schema up with another schema it
|
|
1048
|
+
* is stitched into, or for opting a specific column back into a type of its own:
|
|
1049
|
+
*
|
|
1050
|
+
* ```ts
|
|
1051
|
+
* buildSchema(db, {
|
|
1052
|
+
* enumNameMapper: (info) => (info.enumName === 'status' ? 'PublicationStatus' : undefined),
|
|
1053
|
+
* });
|
|
1054
|
+
* ```
|
|
1055
|
+
*
|
|
1056
|
+
* Two columns the mapper sends to the same name share one type when their values match —
|
|
1057
|
+
* the way to unify inline enums declared separately that mean the same thing. Sending two
|
|
1058
|
+
* *different* value lists to one name throws at build time rather than producing an
|
|
1059
|
+
* invalid schema.
|
|
1060
|
+
*
|
|
1061
|
+
* Return `undefined` to keep the default name.
|
|
1062
|
+
*/
|
|
1063
|
+
enumNameMapper?: EnumNameMapper;
|
|
887
1064
|
};
|
|
888
1065
|
|
|
889
1066
|
/**
|
|
@@ -903,4 +1080,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
903
1080
|
|
|
904
1081
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
905
1082
|
|
|
906
|
-
export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ColumnTypeMapper, type ColumnTypeMapperInfo, type ComplexityConfig, type DeleteResolver, type DeleteSingleResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, GraphQLDecimalString, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, 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 };
|
|
1083
|
+
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 MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationDescriber, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaDocs, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableDescriber, 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
|
@@ -40,6 +40,63 @@ type ColumnTypeMapperInfo = {
|
|
|
40
40
|
* the built-in detection.
|
|
41
41
|
*/
|
|
42
42
|
type ColumnTypeMapper = (column: Column, info: ColumnTypeMapperInfo) => ScalarOverride | undefined;
|
|
43
|
+
/** Everything an {@link EnumNameMapper} needs to name — or opt a column out of — a generated enum type. */
|
|
44
|
+
type EnumNameInfo = {
|
|
45
|
+
/**
|
|
46
|
+
* The name the enum type was declared with (`pgEnum('status', …)`), shared by every column
|
|
47
|
+
* that uses it. `undefined` for an inline value list (`text({ enum: [...] })`,
|
|
48
|
+
* `mysqlEnum(...)`), which belongs to the one column that declares it.
|
|
49
|
+
*/
|
|
50
|
+
enumName: string | undefined;
|
|
51
|
+
/** The Postgres schema the named enum was declared in, when it declares one. */
|
|
52
|
+
schema: string | undefined;
|
|
53
|
+
/** The table's key in the Drizzle schema object. */
|
|
54
|
+
tableName: string;
|
|
55
|
+
/** The column's property name on the table object. */
|
|
56
|
+
columnName: string;
|
|
57
|
+
/** The enum's values, in declaration order. */
|
|
58
|
+
values: readonly string[];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Names a generated GraphQL enum type. Return `undefined` to keep the default name. See
|
|
62
|
+
* `BuildSchemaConfig.enumNameMapper`.
|
|
63
|
+
*/
|
|
64
|
+
type EnumNameMapper = (info: EnumNameInfo) => string | undefined;
|
|
65
|
+
/** Context handed to the documentation and deprecation hooks alongside the column itself. */
|
|
66
|
+
type ColumnDocInfo = {
|
|
67
|
+
/** The table's key in the Drizzle schema object. */
|
|
68
|
+
tableName: string;
|
|
69
|
+
/** The column's property name on the table object. */
|
|
70
|
+
columnName: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Supplies the GraphQL `description` for a generated column field. See
|
|
74
|
+
* `BuildSchemaConfig.describeColumn`.
|
|
75
|
+
*/
|
|
76
|
+
type ColumnDescriber = (column: Column, info: ColumnDocInfo) => string | undefined;
|
|
77
|
+
/**
|
|
78
|
+
* Supplies the GraphQL `deprecationReason` for a generated column field. See
|
|
79
|
+
* `BuildSchemaConfig.deprecateColumn`.
|
|
80
|
+
*/
|
|
81
|
+
type ColumnDeprecator = (column: Column, info: ColumnDocInfo) => string | undefined;
|
|
82
|
+
/** Supplies the GraphQL `description` for a table's object type. See `BuildSchemaConfig.describeTable`. */
|
|
83
|
+
type TableDescriber = (tableName: string) => string | undefined;
|
|
84
|
+
/**
|
|
85
|
+
* Supplies the GraphQL `description` for a relation field. See
|
|
86
|
+
* `BuildSchemaConfig.describeRelation`.
|
|
87
|
+
*/
|
|
88
|
+
type RelationDescriber = (tableName: string, relationName: string) => string | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* The documentation hooks a build was configured with, resolved once and threaded through
|
|
91
|
+
* type generation. Every member is optional; a build with no hooks generates fields with no
|
|
92
|
+
* descriptions at all.
|
|
93
|
+
*/
|
|
94
|
+
type SchemaDocs = {
|
|
95
|
+
describeColumn?: ColumnDescriber;
|
|
96
|
+
describeTable?: TableDescriber;
|
|
97
|
+
describeRelation?: RelationDescriber;
|
|
98
|
+
deprecateColumn?: ColumnDeprecator;
|
|
99
|
+
};
|
|
43
100
|
|
|
44
101
|
type TableNamedRelations = {
|
|
45
102
|
relation: Relation;
|
|
@@ -580,6 +637,38 @@ type SchemaFeatures = {
|
|
|
580
637
|
* @default false
|
|
581
638
|
*/
|
|
582
639
|
upsert?: boolean;
|
|
640
|
+
/**
|
|
641
|
+
* Relation fields on `Create<Table>Input` and `Update<Table>Input`, so a parent row and
|
|
642
|
+
* the rows it is related to can be written in one mutation. Off unless asked for: it adds
|
|
643
|
+
* a field per writable relation to every create and update input.
|
|
644
|
+
*
|
|
645
|
+
* ```graphql
|
|
646
|
+
* createPostsSingle(values: {
|
|
647
|
+
* title: "Hello"
|
|
648
|
+
* author: { connect: { id: { eq: "a1" } } }
|
|
649
|
+
* tags: { create: [{ name: "drizzle" }] }
|
|
650
|
+
* }) { id }
|
|
651
|
+
* ```
|
|
652
|
+
*
|
|
653
|
+
* Each relation field offers `create` and `connect`; the update input adds `disconnect`
|
|
654
|
+
* and, for a to-many relation, `set` (replace the whole set). `disconnect` and `set` are
|
|
655
|
+
* generated only when the foreign key is nullable — there is no way to detach a row whose
|
|
656
|
+
* key is NOT NULL — and many-to-many (`.through()`) relations are not written through at
|
|
657
|
+
* all. Nesting is one level deep: the row a nested `create` inserts takes columns only.
|
|
658
|
+
*
|
|
659
|
+
* The whole tree runs in one transaction (a savepoint when the request already carries
|
|
660
|
+
* one), and a column a relation fills in (`authorId`, when `author: { create: … }` is
|
|
661
|
+
* offered) becomes nullable on the create input, since the relation is the other way to
|
|
662
|
+
* supply it.
|
|
663
|
+
*
|
|
664
|
+
* PostgreSQL and SQLite only. MySQL cannot return the rows it just wrote, which is how a
|
|
665
|
+
* nested write learns the parent's key, so `buildSchema` rejects the flag there. On SQLite
|
|
666
|
+
* the driver must be asynchronous (libsql, D1, …): a synchronous one commits before an
|
|
667
|
+
* awaited statement runs, so `buildSchema` rejects the combination outright.
|
|
668
|
+
*
|
|
669
|
+
* @default false
|
|
670
|
+
*/
|
|
671
|
+
nestedWrites?: boolean;
|
|
583
672
|
/**
|
|
584
673
|
* Makes `where` non-null on the plural `update<Table>` / `delete<Table>` mutations, and
|
|
585
674
|
* rejects a `where` that collapses to no filters (e.g. `where: {}`), so a schema can rule
|
|
@@ -884,6 +973,94 @@ type BuildSchemaConfig = {
|
|
|
884
973
|
* ```
|
|
885
974
|
*/
|
|
886
975
|
onError?: (error: unknown) => unknown;
|
|
976
|
+
/**
|
|
977
|
+
* Supplies the GraphQL `description` for a column, everywhere that column becomes a field:
|
|
978
|
+
* the object type, the create/update inputs, the filter input, and the aggregate
|
|
979
|
+
* `min`/`max`/`group` fields.
|
|
980
|
+
*
|
|
981
|
+
* Nothing is generated by default. The library used to emit the column's own type name
|
|
982
|
+
* ("DateTime", "JSON") as its description, which documented nothing a reader could not see
|
|
983
|
+
* from the type — that is gone, and this hook is what puts real prose in its place. Drizzle
|
|
984
|
+
* carries no column-comment metadata to read, so the text has to come from here.
|
|
985
|
+
*
|
|
986
|
+
* ```ts
|
|
987
|
+
* const columnDocs = { Users: { email: 'Primary contact address. Unique, case-insensitive.' } };
|
|
988
|
+
*
|
|
989
|
+
* buildSchema(db, {
|
|
990
|
+
* describeColumn: (_column, { tableName, columnName }) => columnDocs[tableName]?.[columnName],
|
|
991
|
+
* });
|
|
992
|
+
* ```
|
|
993
|
+
*
|
|
994
|
+
* `tableName` and `columnName` are the Drizzle schema keys. Return `undefined` to leave the
|
|
995
|
+
* field undocumented.
|
|
996
|
+
*/
|
|
997
|
+
describeColumn?: ColumnDescriber;
|
|
998
|
+
/**
|
|
999
|
+
* Supplies the GraphQL `description` for a table's object type.
|
|
1000
|
+
*
|
|
1001
|
+
* ```ts
|
|
1002
|
+
* buildSchema(db, { describeTable: (tableName) => tableDocs[tableName] });
|
|
1003
|
+
* ```
|
|
1004
|
+
*/
|
|
1005
|
+
describeTable?: TableDescriber;
|
|
1006
|
+
/**
|
|
1007
|
+
* Supplies the GraphQL `description` for a relation field on a table's object type.
|
|
1008
|
+
*
|
|
1009
|
+
* ```ts
|
|
1010
|
+
* buildSchema(db, {
|
|
1011
|
+
* describeRelation: (tableName, relationName) =>
|
|
1012
|
+
* tableName === 'Users' && relationName === 'posts' ? 'Posts this user authored.' : undefined,
|
|
1013
|
+
* });
|
|
1014
|
+
* ```
|
|
1015
|
+
*
|
|
1016
|
+
* The generated `<relation>Aggregate` companion fields are not covered — they are derived
|
|
1017
|
+
* fields rather than the relation itself.
|
|
1018
|
+
*/
|
|
1019
|
+
describeRelation?: RelationDescriber;
|
|
1020
|
+
/**
|
|
1021
|
+
* Supplies the GraphQL `deprecationReason` for a column, marking it `@deprecated` on the
|
|
1022
|
+
* object type and on the create/update inputs.
|
|
1023
|
+
*
|
|
1024
|
+
* ```ts
|
|
1025
|
+
* buildSchema(db, {
|
|
1026
|
+
* deprecateColumn: (_column, { columnName }) =>
|
|
1027
|
+
* columnName === 'legacyFlag' ? 'Use `status` instead.' : undefined,
|
|
1028
|
+
* });
|
|
1029
|
+
* ```
|
|
1030
|
+
*
|
|
1031
|
+
* A required input field cannot be deprecated — GraphQL rejects the schema, since a client
|
|
1032
|
+
* has no way to stop sending it — so the reason is dropped on non-null input fields and
|
|
1033
|
+
* kept everywhere else. Filter and orderBy fields are never deprecated either: filtering on
|
|
1034
|
+
* a deprecated column is how a caller finds the rows that still use it.
|
|
1035
|
+
*/
|
|
1036
|
+
deprecateColumn?: ColumnDeprecator;
|
|
1037
|
+
/**
|
|
1038
|
+
* Names the GraphQL enum types generated for enum columns.
|
|
1039
|
+
*
|
|
1040
|
+
* By default a column declared with a named `pgEnum` gets one shared type named after the
|
|
1041
|
+
* enum (`pgEnum('status', …)` → `StatusEnum`), reused by every column declared with that
|
|
1042
|
+
* same `pgEnum` — the database column is the same type, so a client variable typed
|
|
1043
|
+
* `StatusEnum!` is passable to any of them. A column with an inline value list
|
|
1044
|
+
* (`text({ enum: [...] })`, `mysqlEnum(...)`) keeps a per-column type named for its table
|
|
1045
|
+
* and column (`UsersRoleTextEnum`), because its values are shared with nothing.
|
|
1046
|
+
*
|
|
1047
|
+
* This hook overrides the name either way — for lining the schema up with another schema it
|
|
1048
|
+
* is stitched into, or for opting a specific column back into a type of its own:
|
|
1049
|
+
*
|
|
1050
|
+
* ```ts
|
|
1051
|
+
* buildSchema(db, {
|
|
1052
|
+
* enumNameMapper: (info) => (info.enumName === 'status' ? 'PublicationStatus' : undefined),
|
|
1053
|
+
* });
|
|
1054
|
+
* ```
|
|
1055
|
+
*
|
|
1056
|
+
* Two columns the mapper sends to the same name share one type when their values match —
|
|
1057
|
+
* the way to unify inline enums declared separately that mean the same thing. Sending two
|
|
1058
|
+
* *different* value lists to one name throws at build time rather than producing an
|
|
1059
|
+
* invalid schema.
|
|
1060
|
+
*
|
|
1061
|
+
* Return `undefined` to keep the default name.
|
|
1062
|
+
*/
|
|
1063
|
+
enumNameMapper?: EnumNameMapper;
|
|
887
1064
|
};
|
|
888
1065
|
|
|
889
1066
|
/**
|
|
@@ -903,4 +1080,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
903
1080
|
|
|
904
1081
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
905
1082
|
|
|
906
|
-
export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, type ColumnTypeMapper, type ColumnTypeMapperInfo, type ComplexityConfig, type DeleteResolver, type DeleteSingleResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedOutputs, GraphQLBigIntString, GraphQLDecimalString, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, 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 };
|
|
1083
|
+
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 MutationReturnlessResult, type MutationsCore, type QueriesCore, type RelationDescriber, type RelationResolverFactory, type ScalarOverride, type ScalarOverridesConfig, type SchemaDocs, type SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableDescriber, 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 };
|