@pothos/plugin-drizzle 0.11.0 → 0.11.2
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 +15 -0
- package/dts/drizzle-field-builder.d.ts +3 -3
- package/dts/drizzle-field-builder.d.ts.map +1 -1
- package/dts/global-types.d.ts +10 -4
- package/dts/global-types.d.ts.map +1 -1
- package/dts/index.d.ts.map +1 -1
- package/dts/types.d.ts +16 -8
- package/dts/types.d.ts.map +1 -1
- package/esm/drizzle-field-builder.d.ts +2 -2
- package/esm/drizzle-field-builder.d.ts.map +1 -1
- package/esm/drizzle-field-builder.js.map +1 -1
- package/esm/global-types.d.ts +10 -4
- package/esm/global-types.d.ts.map +1 -1
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +7 -1
- package/esm/index.js.map +1 -1
- package/esm/schema-builder.js +8 -2
- package/esm/schema-builder.js.map +1 -1
- package/esm/types.d.ts +16 -8
- package/esm/types.d.ts.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/selections.js +5 -3
- package/esm/utils/selections.js.map +1 -1
- package/lib/drizzle-field-builder.js.map +1 -1
- package/lib/index.js +7 -1
- package/lib/index.js.map +1 -1
- package/lib/schema-builder.js +8 -2
- package/lib/schema-builder.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/selections.js +5 -3
- package/lib/utils/selections.js.map +1 -1
- package/package.json +6 -6
- package/src/drizzle-field-builder.ts +5 -4
- package/src/global-types.ts +3 -3
- package/src/index.ts +9 -4
- package/src/schema-builder.ts +4 -2
- package/src/types.ts +16 -10
- package/src/utils/selections.ts +3 -3
package/src/schema-builder.ts
CHANGED
|
@@ -37,7 +37,8 @@ schemaBuilderProto.drizzleObject = function drizzleObject(table, { select, field
|
|
|
37
37
|
...options.extensions,
|
|
38
38
|
pothosDrizzleModel: table,
|
|
39
39
|
pothosDrizzleTable: getSchemaConfig(this).relations.tablesConfig[table],
|
|
40
|
-
pothosDrizzleSelect:
|
|
40
|
+
pothosDrizzleSelect:
|
|
41
|
+
typeof select === 'object' ? { columns: {}, ...select } : (select ?? true),
|
|
41
42
|
pothosDrizzleLoader: ModelLoader.forModel(table, this),
|
|
42
43
|
},
|
|
43
44
|
name,
|
|
@@ -65,7 +66,8 @@ schemaBuilderProto.drizzleInterface = function drizzleInterface(
|
|
|
65
66
|
...options.extensions,
|
|
66
67
|
pothosDrizzleModel: table,
|
|
67
68
|
pothosDrizzleTable: getSchemaConfig(this).relations.tablesConfig[table],
|
|
68
|
-
pothosDrizzleSelect:
|
|
69
|
+
pothosDrizzleSelect:
|
|
70
|
+
typeof select === 'object' ? { columns: {}, ...select } : (select ?? true),
|
|
69
71
|
pothosDrizzleLoader: ModelLoader.forModel(table, this),
|
|
70
72
|
},
|
|
71
73
|
name,
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type ArgumentRef,
|
|
3
|
+
type DistributeOmit,
|
|
3
4
|
type FieldKind,
|
|
4
5
|
type FieldMap,
|
|
5
6
|
type FieldNullability,
|
|
@@ -209,7 +210,7 @@ export type DrizzleFieldOptions<
|
|
|
209
210
|
ResolveShape,
|
|
210
211
|
ResolveReturnShape
|
|
211
212
|
>,
|
|
212
|
-
'
|
|
213
|
+
'type' | InferredFieldOptionKeys
|
|
213
214
|
> & {
|
|
214
215
|
type: Param;
|
|
215
216
|
resolve: (
|
|
@@ -235,7 +236,7 @@ export type DrizzleFieldWithInputOptions<
|
|
|
235
236
|
InputName extends string,
|
|
236
237
|
Fields extends InputFieldMap,
|
|
237
238
|
ArgRequired extends boolean,
|
|
238
|
-
> =
|
|
239
|
+
> = DistributeOmit<
|
|
239
240
|
DrizzleFieldOptions<
|
|
240
241
|
Types,
|
|
241
242
|
ParentShape,
|
|
@@ -272,8 +273,11 @@ export type DrizzleObjectFieldOptions<
|
|
|
272
273
|
: BuildQueryResult<
|
|
273
274
|
Types['DrizzleRelationsConfig'],
|
|
274
275
|
ExtractTable<Types, ParentShape>,
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
Record<string, unknown> &
|
|
277
|
+
// biome-ignore lint/suspicious/noExplicitAny: this is fine
|
|
278
|
+
Select extends (...args: any[]) => infer R
|
|
279
|
+
? R & { columns: {} }
|
|
280
|
+
: Select & { columns: {} }
|
|
277
281
|
> &
|
|
278
282
|
ParentShape,
|
|
279
283
|
typeof drizzleTableName
|
|
@@ -357,7 +361,7 @@ export type RelatedFieldOptions<
|
|
|
357
361
|
},
|
|
358
362
|
ResolveReturnShape
|
|
359
363
|
>,
|
|
360
|
-
'description' | '
|
|
364
|
+
'description' | 'select' | 'type' | InferredFieldOptionKeys
|
|
361
365
|
> & {
|
|
362
366
|
description?: string | false;
|
|
363
367
|
// biome-ignore lint/suspicious/noExplicitAny: this is fine
|
|
@@ -400,7 +404,9 @@ export type VariantFieldOptions<
|
|
|
400
404
|
ExtractTable<Types, Shape>,
|
|
401
405
|
Record<string, unknown> &
|
|
402
406
|
// biome-ignore lint/suspicious/noExplicitAny: this is fine
|
|
403
|
-
|
|
407
|
+
ResolveShape extends (...args: any[]) => infer R
|
|
408
|
+
? R & { columns: {} }
|
|
409
|
+
: ResolveShape & { columns: {} }
|
|
404
410
|
> &
|
|
405
411
|
Shape,
|
|
406
412
|
typeof drizzleTableName
|
|
@@ -516,7 +522,7 @@ export type DrizzleConnectionFieldOptions<
|
|
|
516
522
|
ParentShape,
|
|
517
523
|
ResolveReturnShape
|
|
518
524
|
>,
|
|
519
|
-
'args' | '
|
|
525
|
+
'args' | 'type' | InferredFieldOptionKeys
|
|
520
526
|
> &
|
|
521
527
|
Omit<
|
|
522
528
|
PothosSchemaTypes.ConnectionFieldOptions<
|
|
@@ -529,7 +535,7 @@ export type DrizzleConnectionFieldOptions<
|
|
|
529
535
|
Args,
|
|
530
536
|
ResolveReturnShape
|
|
531
537
|
>,
|
|
532
|
-
'
|
|
538
|
+
'type' | InferredFieldOptionKeys
|
|
533
539
|
> &
|
|
534
540
|
(InputShapeFromFields<Args> &
|
|
535
541
|
PothosSchemaTypes.DefaultConnectionArguments extends infer ConnectionArgs
|
|
@@ -577,7 +583,7 @@ export type RelatedConnectionOptions<
|
|
|
577
583
|
(InputFieldMap extends Args ? {} : Args),
|
|
578
584
|
unknown
|
|
579
585
|
>,
|
|
580
|
-
'args' | '
|
|
586
|
+
'args' | 'type' | InferredFieldOptionKeys
|
|
581
587
|
> &
|
|
582
588
|
Omit<
|
|
583
589
|
PothosSchemaTypes.ConnectionFieldOptions<
|
|
@@ -590,7 +596,7 @@ export type RelatedConnectionOptions<
|
|
|
590
596
|
Args,
|
|
591
597
|
unknown
|
|
592
598
|
>,
|
|
593
|
-
'
|
|
599
|
+
'type' | InferredFieldOptionKeys
|
|
594
600
|
> &
|
|
595
601
|
(InputShapeFromFields<Args> &
|
|
596
602
|
PothosSchemaTypes.DefaultConnectionArguments extends infer ConnectionArgs
|
package/src/utils/selections.ts
CHANGED
|
@@ -126,7 +126,7 @@ export function mergeSelection(
|
|
|
126
126
|
extras,
|
|
127
127
|
columns,
|
|
128
128
|
...query
|
|
129
|
-
} = typeof selection === 'boolean' ? {} : selection;
|
|
129
|
+
} = typeof selection === 'boolean' ? (selection === true ? {} : { columns: {} }) : selection;
|
|
130
130
|
if (withSelection) {
|
|
131
131
|
for (const [key, value] of Object.entries(withSelection)) {
|
|
132
132
|
const relation = state.table.relations[key];
|
|
@@ -155,11 +155,11 @@ export function mergeSelection(
|
|
|
155
155
|
return;
|
|
156
156
|
}
|
|
157
157
|
|
|
158
|
-
if (columns) {
|
|
158
|
+
if (columns && !state.allColumns) {
|
|
159
159
|
for (const key of Object.keys(columns)) {
|
|
160
160
|
state.columns.add(key);
|
|
161
161
|
}
|
|
162
|
-
} else
|
|
162
|
+
} else {
|
|
163
163
|
state.allColumns = true;
|
|
164
164
|
}
|
|
165
165
|
|