@pothos/plugin-drizzle 0.12.0 → 0.13.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/CHANGELOG.md +16 -0
- package/dts/drizzle-field-builder.d.ts +5 -13
- package/dts/drizzle-field-builder.d.ts.map +1 -1
- package/dts/global-types.d.ts +12 -4
- package/dts/global-types.d.ts.map +1 -1
- package/dts/interface-ref.d.ts +3 -1
- package/dts/interface-ref.d.ts.map +1 -1
- package/dts/object-ref.d.ts +3 -1
- package/dts/object-ref.d.ts.map +1 -1
- package/dts/types.d.ts +23 -6
- package/dts/types.d.ts.map +1 -1
- package/esm/drizzle-field-builder.d.ts +8 -8
- package/esm/drizzle-field-builder.d.ts.map +1 -1
- package/esm/drizzle-field-builder.js +5 -7
- package/esm/drizzle-field-builder.js.map +1 -1
- package/esm/global-types.d.ts +12 -4
- package/esm/global-types.d.ts.map +1 -1
- package/esm/interface-ref.d.ts +3 -1
- package/esm/interface-ref.d.ts.map +1 -1
- package/esm/interface-ref.js.map +1 -1
- package/esm/object-ref.d.ts +3 -1
- package/esm/object-ref.d.ts.map +1 -1
- package/esm/object-ref.js.map +1 -1
- package/esm/types.d.ts +24 -7
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/lib/drizzle-field-builder.js +4 -6
- package/lib/drizzle-field-builder.js.map +1 -1
- package/lib/interface-ref.js.map +1 -1
- package/lib/object-ref.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +9 -9
- package/src/drizzle-field-builder.ts +25 -48
- package/src/field-builder.ts +1 -1
- package/src/global-types.ts +29 -12
- package/src/interface-ref.ts +8 -1
- package/src/object-ref.ts +8 -1
- package/src/types.ts +22 -8
package/src/global-types.ts
CHANGED
|
@@ -282,16 +282,26 @@ declare global {
|
|
|
282
282
|
? [
|
|
283
283
|
ObjectRef<
|
|
284
284
|
Types,
|
|
285
|
-
BuildQueryResult<
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
| BuildQueryResult<
|
|
286
|
+
Types['DrizzleRelations'],
|
|
287
|
+
Types['DrizzleRelations'][Table],
|
|
288
|
+
true
|
|
289
|
+
>
|
|
290
|
+
| {
|
|
291
|
+
$pothosQueryFor: Table | undefined;
|
|
292
|
+
}
|
|
290
293
|
>,
|
|
291
294
|
]
|
|
292
295
|
: ObjectRef<
|
|
293
296
|
Types,
|
|
294
|
-
BuildQueryResult<
|
|
297
|
+
| BuildQueryResult<
|
|
298
|
+
Types['DrizzleRelations'],
|
|
299
|
+
Types['DrizzleRelations'][Table],
|
|
300
|
+
true
|
|
301
|
+
>
|
|
302
|
+
| {
|
|
303
|
+
$pothosQueryFor: Table | undefined;
|
|
304
|
+
}
|
|
295
305
|
>,
|
|
296
306
|
>(
|
|
297
307
|
options: DrizzleFieldOptions<
|
|
@@ -321,11 +331,15 @@ declare global {
|
|
|
321
331
|
infer S
|
|
322
332
|
>
|
|
323
333
|
? S
|
|
324
|
-
:
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
334
|
+
:
|
|
335
|
+
| BuildQueryResult<
|
|
336
|
+
Types['DrizzleRelations'],
|
|
337
|
+
Types['DrizzleRelations'][Type & keyof Types['DrizzleRelations']],
|
|
338
|
+
true
|
|
339
|
+
>
|
|
340
|
+
| {
|
|
341
|
+
$pothosQueryFor: Type | undefined;
|
|
342
|
+
},
|
|
329
343
|
const ConnectionInterfaces extends InterfaceParam<Types>[] = [],
|
|
330
344
|
const EdgeInterfaces extends InterfaceParam<Types>[] = [],
|
|
331
345
|
>(
|
|
@@ -408,7 +422,10 @@ declare global {
|
|
|
408
422
|
: never,
|
|
409
423
|
Type extends TypeParam<Types> = ObjectRef<
|
|
410
424
|
Types,
|
|
411
|
-
BuildQueryResult<Types['DrizzleRelations'], Types['DrizzleRelations'][Table], true>
|
|
425
|
+
| BuildQueryResult<Types['DrizzleRelations'], Types['DrizzleRelations'][Table], true>
|
|
426
|
+
| {
|
|
427
|
+
$pothosQueryFor: Table | undefined;
|
|
428
|
+
}
|
|
412
429
|
>,
|
|
413
430
|
>(
|
|
414
431
|
options: DrizzleFieldWithInputOptions<
|
package/src/interface-ref.ts
CHANGED
|
@@ -15,7 +15,14 @@ export class DrizzleInterfaceRef<
|
|
|
15
15
|
Types extends SchemaTypes,
|
|
16
16
|
Table extends keyof Types['DrizzleRelations'] = keyof Types['DrizzleRelations'],
|
|
17
17
|
T = {},
|
|
18
|
-
> extends InterfaceRef<
|
|
18
|
+
> extends InterfaceRef<
|
|
19
|
+
Types,
|
|
20
|
+
| T
|
|
21
|
+
| {
|
|
22
|
+
$pothosQueryFor: Table | undefined;
|
|
23
|
+
},
|
|
24
|
+
T
|
|
25
|
+
> {
|
|
19
26
|
[drizzleTableKey]!: Types['DrizzleRelations'][Table];
|
|
20
27
|
|
|
21
28
|
tableName: string;
|
package/src/object-ref.ts
CHANGED
|
@@ -13,7 +13,14 @@ export class DrizzleObjectRef<
|
|
|
13
13
|
Types extends SchemaTypes,
|
|
14
14
|
Table extends keyof Types['DrizzleRelations'] = keyof Types['DrizzleRelations'],
|
|
15
15
|
T = {},
|
|
16
|
-
> extends ObjectRef<
|
|
16
|
+
> extends ObjectRef<
|
|
17
|
+
Types,
|
|
18
|
+
| T
|
|
19
|
+
| {
|
|
20
|
+
$pothosQueryFor: Table | undefined;
|
|
21
|
+
},
|
|
22
|
+
T
|
|
23
|
+
> {
|
|
17
24
|
[drizzleTableKey]!: Types['DrizzleRelations'][Table];
|
|
18
25
|
|
|
19
26
|
[abstractReturnShapeKey]!: WithBrand<T>;
|
package/src/types.ts
CHANGED
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
DBQueryConfig,
|
|
34
34
|
Many,
|
|
35
35
|
Relation,
|
|
36
|
+
SQL,
|
|
36
37
|
Table,
|
|
37
38
|
TableRelationalConfig,
|
|
38
39
|
} from 'drizzle-orm';
|
|
@@ -214,7 +215,14 @@ export type DrizzleFieldOptions<
|
|
|
214
215
|
> & {
|
|
215
216
|
type: Param;
|
|
216
217
|
resolve: (
|
|
217
|
-
query: <T extends QueryForDrizzleField<Types, Param, Table
|
|
218
|
+
query: <T extends QueryForDrizzleField<Types, Param, Table> = {}>(
|
|
219
|
+
selection?: T,
|
|
220
|
+
) => Omit<T, 'columns' | 'extra'> & {
|
|
221
|
+
columns: T extends { columns: infer C extends {} } ? C : {};
|
|
222
|
+
extras: {
|
|
223
|
+
$pothosQueryFor: SQL<Table | undefined>;
|
|
224
|
+
} & (T extends { extra: infer E } ? E : {});
|
|
225
|
+
},
|
|
218
226
|
parent: ParentShape,
|
|
219
227
|
args: InputShapeFromFields<Args>,
|
|
220
228
|
ctx: Types['Context'],
|
|
@@ -458,9 +466,10 @@ export type QueryForDrizzleField<
|
|
|
458
466
|
Types extends SchemaTypes,
|
|
459
467
|
Param,
|
|
460
468
|
Table extends keyof Types['DrizzleRelations'],
|
|
461
|
-
> =
|
|
462
|
-
|
|
463
|
-
|
|
469
|
+
> = DBQueryConfig<
|
|
470
|
+
Param extends [unknown] ? 'one' : 'many',
|
|
471
|
+
Types['DrizzleRelations'],
|
|
472
|
+
Types['DrizzleRelations'][Table]
|
|
464
473
|
>;
|
|
465
474
|
|
|
466
475
|
export type QueryForRelatedConnection<
|
|
@@ -536,14 +545,18 @@ export type DrizzleConnectionFieldOptions<
|
|
|
536
545
|
maxSize?: number | ((args: ConnectionArgs, ctx: Types['Context']) => number);
|
|
537
546
|
|
|
538
547
|
resolve: (
|
|
539
|
-
query: <T
|
|
540
|
-
selection?: T,
|
|
541
|
-
) => Omit<T, 'orderBy'> & {
|
|
548
|
+
query: <T = {}>(
|
|
549
|
+
selection?: T & QueryForDrizzleConnection<Types, TableConfig>,
|
|
550
|
+
) => Omit<T, 'orderBy' | 'columns' | 'extra'> & {
|
|
551
|
+
columns: T extends { columns: infer C extends {} } ? C : {};
|
|
542
552
|
orderBy: {
|
|
543
553
|
[K in TableConfig['table']['_'] extends { columns: infer Columns }
|
|
544
554
|
? keyof Columns
|
|
545
555
|
: never]?: 'asc' | 'desc' | undefined;
|
|
546
556
|
};
|
|
557
|
+
extras: {
|
|
558
|
+
$pothosQueryFor: () => SQL<TableConfig['name'] | undefined>;
|
|
559
|
+
} & (T extends { extra: infer E } ? E : {});
|
|
547
560
|
},
|
|
548
561
|
parent: ParentShape,
|
|
549
562
|
args: ConnectionArgs,
|
|
@@ -564,6 +577,7 @@ export type RelatedConnectionOptions<
|
|
|
564
577
|
Field extends keyof Table['relations'],
|
|
565
578
|
Nullable extends boolean,
|
|
566
579
|
Args extends InputFieldMap,
|
|
580
|
+
Type = unknown,
|
|
567
581
|
NodeTable extends
|
|
568
582
|
TableRelationalConfig = Types['DrizzleRelations'][Table['relations'][Field]['targetTable']['_']['name']],
|
|
569
583
|
> = Omit<
|
|
@@ -608,7 +622,7 @@ export type RelatedConnectionOptions<
|
|
|
608
622
|
>;
|
|
609
623
|
query?: QueryForRelatedConnection<Types, NodeTable, ConnectionArgs>;
|
|
610
624
|
// biome-ignore lint/suspicious/noExplicitAny: this is fine
|
|
611
|
-
type?: DrizzleRef<any, Table['relations'][Field]['targetTable']['_']['name']>;
|
|
625
|
+
type?: Type & DrizzleRef<any, Table['relations'][Field]['targetTable']['_']['name']>;
|
|
612
626
|
|
|
613
627
|
defaultSize?: number | ((args: ConnectionArgs, ctx: Types['Context']) => number);
|
|
614
628
|
maxSize?: number | ((args: ConnectionArgs, ctx: Types['Context']) => number);
|