@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.
@@ -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: select ?? true,
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: select ?? true,
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
- 'resolve' | 'type'
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
- > = Omit<
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
- // biome-ignore lint/suspicious/noExplicitAny: this is fine
276
- Record<string, unknown> & (Select extends (...args: any[]) => infer R ? R : Select)
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' | 'resolve' | 'select' | 'type'
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
- (ResolveShape extends (...args: any[]) => infer R ? R : ResolveShape)
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' | 'resolve' | 'type'
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
- 'resolve' | 'type'
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' | 'resolve' | 'type'
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
- 'resolve' | 'type'
599
+ 'type' | InferredFieldOptionKeys
594
600
  > &
595
601
  (InputShapeFromFields<Args> &
596
602
  PothosSchemaTypes.DefaultConnectionArguments extends infer ConnectionArgs
@@ -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 if (selection === true) {
162
+ } else {
163
163
  state.allColumns = true;
164
164
  }
165
165