@vantreeseba/drizzle-graphql 5.3.0 → 5.5.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.cjs +963 -391
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +73 -1
- package/dist/index.d.ts +73 -1
- package/dist/index.js +963 -391
- package/dist/index.js.map +1 -1
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -233,6 +233,17 @@ type UpdateArgs<TTable extends Table> = Partial<{
|
|
|
233
233
|
set: GetRemappedTableUpdateDataType<TTable>;
|
|
234
234
|
where?: Filters<TTable>;
|
|
235
235
|
}>;
|
|
236
|
+
/**
|
|
237
|
+
* One entry of an `update<Table>Many` mutation: the rows `where` matches get this
|
|
238
|
+
* entry's `set` applied. An omitted `where` matches every row, same as `update<Table>`.
|
|
239
|
+
*/
|
|
240
|
+
type UpdateManyEntry<TTable extends Table> = {
|
|
241
|
+
where?: Filters<TTable>;
|
|
242
|
+
set: GetRemappedTableUpdateDataType<TTable>;
|
|
243
|
+
};
|
|
244
|
+
type UpdateManyArgs<TTable extends Table> = {
|
|
245
|
+
updates: Array<UpdateManyEntry<TTable>>;
|
|
246
|
+
};
|
|
236
247
|
/**
|
|
237
248
|
* The `onConflict` argument of the generated upsert mutations.
|
|
238
249
|
*
|
|
@@ -272,6 +283,13 @@ type InsertResolver<TTable extends Table, IsReturnless extends boolean> = (sourc
|
|
|
272
283
|
/** Resolver for `create<Table>`: an array of rows in, an array of rows out. */
|
|
273
284
|
type InsertArrResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: Partial<InsertArgs<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? Array<GetRemappedTableDataType<TTable>> : MutationReturnlessResult>;
|
|
274
285
|
type UpdateResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: UpdateArgs<TTable>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? GetRemappedTableDataType<TTable> | undefined : MutationReturnlessResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Resolver for `update<Table>Many`: per-entry `set`/`where` pairs applied in input order
|
|
288
|
+
* inside one transaction. Where the dialect returns rows, the result holds each entry's
|
|
289
|
+
* updated rows in entry order, with `null` standing in for an entry whose `where`
|
|
290
|
+
* matched no rows.
|
|
291
|
+
*/
|
|
292
|
+
type UpdateManyResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: UpdateManyArgs<TTable>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? Array<GetRemappedTableDataType<TTable> | null> : MutationReturnlessResult>;
|
|
275
293
|
/**
|
|
276
294
|
* Resolver for `update<Table>Single`: `where` required, the single (nullable) affected row
|
|
277
295
|
* out. Throws before writing anything when `where` matches more than one row.
|
|
@@ -403,6 +421,16 @@ type MutationsCore<TSchemaTables extends Record<string, Table>, TInputs extends
|
|
|
403
421
|
};
|
|
404
422
|
resolve: UpdateResolver<TSchemaTables[TName], IsReturnless>;
|
|
405
423
|
} : never;
|
|
424
|
+
} & {
|
|
425
|
+
[TName in keyof TSchemaTables as TName extends string ? `update${Capitalize<TName>}Many` : never]: TName extends string ? {
|
|
426
|
+
type: IsReturnless extends true ? TOutputs['MutationReturn'] extends GraphQLObjectType ? TOutputs['MutationReturn'] : never : GraphQLNonNull<GraphQLList<TOutputs[`${Capitalize<TName>}Item`]>>;
|
|
427
|
+
args: {
|
|
428
|
+
updates: {
|
|
429
|
+
type: GraphQLNonNull<GraphQLList<GraphQLNonNull<TInputs[`${Capitalize<TName>}UpdateManyInput`]>>>;
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
resolve: UpdateManyResolver<TSchemaTables[TName], IsReturnless>;
|
|
433
|
+
} : never;
|
|
406
434
|
} & {
|
|
407
435
|
[TName in keyof TSchemaTables as TName extends string ? `update${Capitalize<TName>}Single` : never]: TName extends string ? {
|
|
408
436
|
type: IsReturnless extends true ? TOutputs['MutationReturn'] extends GraphQLObjectType ? TOutputs['MutationReturn'] : never : TOutputs[`${Capitalize<TName>}Item`];
|
|
@@ -441,6 +469,8 @@ type GeneratedInputs<TSchema extends Record<string, Table>> = {
|
|
|
441
469
|
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}InsertInput` : never]: GraphQLInputObjectType;
|
|
442
470
|
} & {
|
|
443
471
|
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}UpdateInput` : never]: GraphQLInputObjectType;
|
|
472
|
+
} & {
|
|
473
|
+
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}UpdateManyInput` : never]: GraphQLInputObjectType;
|
|
444
474
|
} & {
|
|
445
475
|
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}OrderBy` : never]: GraphQLInputObjectType;
|
|
446
476
|
} & {
|
|
@@ -496,6 +526,14 @@ type SchemaFeatures = {
|
|
|
496
526
|
insert?: boolean;
|
|
497
527
|
/** `update<Table>` / `update<Table>Single` mutations. @default true */
|
|
498
528
|
update?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* `update<Table>Many` mutations — batch update with a per-entry `set` and `where`,
|
|
531
|
+
* executed inside one transaction. Only generated when `update` is also enabled,
|
|
532
|
+
* since the entries reuse the update `set` input.
|
|
533
|
+
*
|
|
534
|
+
* @default true
|
|
535
|
+
*/
|
|
536
|
+
updateMany?: boolean;
|
|
499
537
|
/** `delete<Table>` / `delete<Table>Single` mutations. @default true */
|
|
500
538
|
delete?: boolean;
|
|
501
539
|
/**
|
|
@@ -655,6 +693,40 @@ type BuildSchemaConfig = {
|
|
|
655
693
|
* queries are always generated, so `Query` is never empty.
|
|
656
694
|
*/
|
|
657
695
|
features?: SchemaFeatures;
|
|
696
|
+
/**
|
|
697
|
+
* Automatic transactions for GraphQL documents that fire more than one mutation.
|
|
698
|
+
*
|
|
699
|
+
* `'none'` (default) — every root mutation field runs on its own connection, so a failure
|
|
700
|
+
* mid-document leaves the earlier mutations committed (today's behavior).
|
|
701
|
+
*
|
|
702
|
+
* `'auto'` — when a request's document selects more than one root mutation field, the
|
|
703
|
+
* library opens `db.transaction()` once for the whole request and runs every mutation
|
|
704
|
+
* field (and the reads nested under them) inside it. The transaction commits when the
|
|
705
|
+
* last mutation field completes and rolls back when any of them fails; mutation fields
|
|
706
|
+
* after a failure are not executed against the rolled-back transaction — they fail fast.
|
|
707
|
+
* The object form additionally sets the safety timeout (default 30000ms) after which an
|
|
708
|
+
* abandoned transaction — e.g. the host server stopped calling resolvers because of a
|
|
709
|
+
* non-null completion error — is rolled back instead of leaking a connection.
|
|
710
|
+
*
|
|
711
|
+
* Never nests: a caller-supplied executor on the GraphQL context under
|
|
712
|
+
* `drizzleExecutorKey` always wins, and the library opens nothing of its own.
|
|
713
|
+
*
|
|
714
|
+
* Requirements and caveats:
|
|
715
|
+
* - The driver must support `db.transaction()` (e.g. `neon-http` does not). For SQLite
|
|
716
|
+
* only asynchronous drivers (libsql, better-sqlite3 is synchronous) can hold a
|
|
717
|
+
* transaction open across resolvers; `buildSchema` throws for synchronous ones.
|
|
718
|
+
* - The GraphQL context value must be a fresh object per request (every mainstream
|
|
719
|
+
* server does this) — it keys the per-request transaction state.
|
|
720
|
+
* - Documents that mix in mutation fields not generated by this build (consumer
|
|
721
|
+
* extensions) are left alone: their completion cannot be tracked, so no transaction
|
|
722
|
+
* is opened.
|
|
723
|
+
*
|
|
724
|
+
* @default 'none'
|
|
725
|
+
*/
|
|
726
|
+
transactions?: 'auto' | 'none' | {
|
|
727
|
+
mode: 'auto';
|
|
728
|
+
timeoutMs?: number;
|
|
729
|
+
};
|
|
658
730
|
/**
|
|
659
731
|
* Optional mapper from table key to singular/plural name pair.
|
|
660
732
|
* When provided for a table, overrides the default (table key) naming for GraphQL type names,
|
|
@@ -745,4 +817,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
745
817
|
|
|
746
818
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
747
819
|
|
|
748
|
-
export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, 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 SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableNamedRelations, type UpdateResolver, type UpdateSingleResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
|
|
820
|
+
export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, 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 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 };
|
package/dist/index.d.ts
CHANGED
|
@@ -233,6 +233,17 @@ type UpdateArgs<TTable extends Table> = Partial<{
|
|
|
233
233
|
set: GetRemappedTableUpdateDataType<TTable>;
|
|
234
234
|
where?: Filters<TTable>;
|
|
235
235
|
}>;
|
|
236
|
+
/**
|
|
237
|
+
* One entry of an `update<Table>Many` mutation: the rows `where` matches get this
|
|
238
|
+
* entry's `set` applied. An omitted `where` matches every row, same as `update<Table>`.
|
|
239
|
+
*/
|
|
240
|
+
type UpdateManyEntry<TTable extends Table> = {
|
|
241
|
+
where?: Filters<TTable>;
|
|
242
|
+
set: GetRemappedTableUpdateDataType<TTable>;
|
|
243
|
+
};
|
|
244
|
+
type UpdateManyArgs<TTable extends Table> = {
|
|
245
|
+
updates: Array<UpdateManyEntry<TTable>>;
|
|
246
|
+
};
|
|
236
247
|
/**
|
|
237
248
|
* The `onConflict` argument of the generated upsert mutations.
|
|
238
249
|
*
|
|
@@ -272,6 +283,13 @@ type InsertResolver<TTable extends Table, IsReturnless extends boolean> = (sourc
|
|
|
272
283
|
/** Resolver for `create<Table>`: an array of rows in, an array of rows out. */
|
|
273
284
|
type InsertArrResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: Partial<InsertArgs<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? Array<GetRemappedTableDataType<TTable>> : MutationReturnlessResult>;
|
|
274
285
|
type UpdateResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: UpdateArgs<TTable>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? GetRemappedTableDataType<TTable> | undefined : MutationReturnlessResult>;
|
|
286
|
+
/**
|
|
287
|
+
* Resolver for `update<Table>Many`: per-entry `set`/`where` pairs applied in input order
|
|
288
|
+
* inside one transaction. Where the dialect returns rows, the result holds each entry's
|
|
289
|
+
* updated rows in entry order, with `null` standing in for an entry whose `where`
|
|
290
|
+
* matched no rows.
|
|
291
|
+
*/
|
|
292
|
+
type UpdateManyResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: UpdateManyArgs<TTable>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? Array<GetRemappedTableDataType<TTable> | null> : MutationReturnlessResult>;
|
|
275
293
|
/**
|
|
276
294
|
* Resolver for `update<Table>Single`: `where` required, the single (nullable) affected row
|
|
277
295
|
* out. Throws before writing anything when `where` matches more than one row.
|
|
@@ -403,6 +421,16 @@ type MutationsCore<TSchemaTables extends Record<string, Table>, TInputs extends
|
|
|
403
421
|
};
|
|
404
422
|
resolve: UpdateResolver<TSchemaTables[TName], IsReturnless>;
|
|
405
423
|
} : never;
|
|
424
|
+
} & {
|
|
425
|
+
[TName in keyof TSchemaTables as TName extends string ? `update${Capitalize<TName>}Many` : never]: TName extends string ? {
|
|
426
|
+
type: IsReturnless extends true ? TOutputs['MutationReturn'] extends GraphQLObjectType ? TOutputs['MutationReturn'] : never : GraphQLNonNull<GraphQLList<TOutputs[`${Capitalize<TName>}Item`]>>;
|
|
427
|
+
args: {
|
|
428
|
+
updates: {
|
|
429
|
+
type: GraphQLNonNull<GraphQLList<GraphQLNonNull<TInputs[`${Capitalize<TName>}UpdateManyInput`]>>>;
|
|
430
|
+
};
|
|
431
|
+
};
|
|
432
|
+
resolve: UpdateManyResolver<TSchemaTables[TName], IsReturnless>;
|
|
433
|
+
} : never;
|
|
406
434
|
} & {
|
|
407
435
|
[TName in keyof TSchemaTables as TName extends string ? `update${Capitalize<TName>}Single` : never]: TName extends string ? {
|
|
408
436
|
type: IsReturnless extends true ? TOutputs['MutationReturn'] extends GraphQLObjectType ? TOutputs['MutationReturn'] : never : TOutputs[`${Capitalize<TName>}Item`];
|
|
@@ -441,6 +469,8 @@ type GeneratedInputs<TSchema extends Record<string, Table>> = {
|
|
|
441
469
|
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}InsertInput` : never]: GraphQLInputObjectType;
|
|
442
470
|
} & {
|
|
443
471
|
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}UpdateInput` : never]: GraphQLInputObjectType;
|
|
472
|
+
} & {
|
|
473
|
+
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}UpdateManyInput` : never]: GraphQLInputObjectType;
|
|
444
474
|
} & {
|
|
445
475
|
[TName in keyof TSchema as TName extends string ? `${Capitalize<TName>}OrderBy` : never]: GraphQLInputObjectType;
|
|
446
476
|
} & {
|
|
@@ -496,6 +526,14 @@ type SchemaFeatures = {
|
|
|
496
526
|
insert?: boolean;
|
|
497
527
|
/** `update<Table>` / `update<Table>Single` mutations. @default true */
|
|
498
528
|
update?: boolean;
|
|
529
|
+
/**
|
|
530
|
+
* `update<Table>Many` mutations — batch update with a per-entry `set` and `where`,
|
|
531
|
+
* executed inside one transaction. Only generated when `update` is also enabled,
|
|
532
|
+
* since the entries reuse the update `set` input.
|
|
533
|
+
*
|
|
534
|
+
* @default true
|
|
535
|
+
*/
|
|
536
|
+
updateMany?: boolean;
|
|
499
537
|
/** `delete<Table>` / `delete<Table>Single` mutations. @default true */
|
|
500
538
|
delete?: boolean;
|
|
501
539
|
/**
|
|
@@ -655,6 +693,40 @@ type BuildSchemaConfig = {
|
|
|
655
693
|
* queries are always generated, so `Query` is never empty.
|
|
656
694
|
*/
|
|
657
695
|
features?: SchemaFeatures;
|
|
696
|
+
/**
|
|
697
|
+
* Automatic transactions for GraphQL documents that fire more than one mutation.
|
|
698
|
+
*
|
|
699
|
+
* `'none'` (default) — every root mutation field runs on its own connection, so a failure
|
|
700
|
+
* mid-document leaves the earlier mutations committed (today's behavior).
|
|
701
|
+
*
|
|
702
|
+
* `'auto'` — when a request's document selects more than one root mutation field, the
|
|
703
|
+
* library opens `db.transaction()` once for the whole request and runs every mutation
|
|
704
|
+
* field (and the reads nested under them) inside it. The transaction commits when the
|
|
705
|
+
* last mutation field completes and rolls back when any of them fails; mutation fields
|
|
706
|
+
* after a failure are not executed against the rolled-back transaction — they fail fast.
|
|
707
|
+
* The object form additionally sets the safety timeout (default 30000ms) after which an
|
|
708
|
+
* abandoned transaction — e.g. the host server stopped calling resolvers because of a
|
|
709
|
+
* non-null completion error — is rolled back instead of leaking a connection.
|
|
710
|
+
*
|
|
711
|
+
* Never nests: a caller-supplied executor on the GraphQL context under
|
|
712
|
+
* `drizzleExecutorKey` always wins, and the library opens nothing of its own.
|
|
713
|
+
*
|
|
714
|
+
* Requirements and caveats:
|
|
715
|
+
* - The driver must support `db.transaction()` (e.g. `neon-http` does not). For SQLite
|
|
716
|
+
* only asynchronous drivers (libsql, better-sqlite3 is synchronous) can hold a
|
|
717
|
+
* transaction open across resolvers; `buildSchema` throws for synchronous ones.
|
|
718
|
+
* - The GraphQL context value must be a fresh object per request (every mainstream
|
|
719
|
+
* server does this) — it keys the per-request transaction state.
|
|
720
|
+
* - Documents that mix in mutation fields not generated by this build (consumer
|
|
721
|
+
* extensions) are left alone: their completion cannot be tracked, so no transaction
|
|
722
|
+
* is opened.
|
|
723
|
+
*
|
|
724
|
+
* @default 'none'
|
|
725
|
+
*/
|
|
726
|
+
transactions?: 'auto' | 'none' | {
|
|
727
|
+
mode: 'auto';
|
|
728
|
+
timeoutMs?: number;
|
|
729
|
+
};
|
|
658
730
|
/**
|
|
659
731
|
* Optional mapper from table key to singular/plural name pair.
|
|
660
732
|
* When provided for a table, overrides the default (table key) naming for GraphQL type names,
|
|
@@ -745,4 +817,4 @@ declare const GraphQLDecimalString: GraphQLScalarType<string, string>;
|
|
|
745
817
|
|
|
746
818
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
747
819
|
|
|
748
|
-
export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, 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 SchemaFeatures, type SelectResolver, type SelectSingleResolver, type TableNamedRelations, type UpdateResolver, type UpdateSingleResolver, type UpsertArgs, type UpsertArrResolver, type UpsertConflictArgs, type UpsertResolver, buildSchema, createRelationResolverFactory, defaultErrorMapper, drizzleExecutorKey, extractFilters, extractOrderBy, extractRelationJoinColumns };
|
|
820
|
+
export { type AggregateResolver, type AnyDrizzleDB, type BuildSchemaConfig, 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 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 };
|