@pothos/plugin-drizzle 0.11.2 → 0.12.1

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dts/connection-helpers.d.ts +7 -5
  3. package/dts/connection-helpers.d.ts.map +1 -1
  4. package/dts/drizzle-field-builder.d.ts +2 -2
  5. package/dts/drizzle-field-builder.d.ts.map +1 -1
  6. package/dts/global-types.d.ts +23 -24
  7. package/dts/global-types.d.ts.map +1 -1
  8. package/dts/interface-ref.d.ts +3 -3
  9. package/dts/interface-ref.d.ts.map +1 -1
  10. package/dts/model-loader.d.ts.map +1 -1
  11. package/dts/node-ref.d.ts +1 -1
  12. package/dts/node-ref.d.ts.map +1 -1
  13. package/dts/object-ref.d.ts +2 -2
  14. package/dts/object-ref.d.ts.map +1 -1
  15. package/dts/types.d.ts +35 -31
  16. package/dts/types.d.ts.map +1 -1
  17. package/dts/utils/config.d.ts.map +1 -1
  18. package/dts/utils/cursors.d.ts +3 -3
  19. package/dts/utils/cursors.d.ts.map +1 -1
  20. package/dts/utils/selections.d.ts +1 -1
  21. package/dts/utils/selections.d.ts.map +1 -1
  22. package/esm/connection-helpers.d.ts +7 -5
  23. package/esm/connection-helpers.d.ts.map +1 -1
  24. package/esm/connection-helpers.js +2 -2
  25. package/esm/connection-helpers.js.map +1 -1
  26. package/esm/drizzle-field-builder.d.ts +2 -2
  27. package/esm/drizzle-field-builder.d.ts.map +1 -1
  28. package/esm/drizzle-field-builder.js +13 -19
  29. package/esm/drizzle-field-builder.js.map +1 -1
  30. package/esm/global-types.d.ts +34 -35
  31. package/esm/global-types.d.ts.map +1 -1
  32. package/esm/global-types.js.map +1 -1
  33. package/esm/interface-ref.d.ts +3 -3
  34. package/esm/interface-ref.d.ts.map +1 -1
  35. package/esm/model-loader.d.ts.map +1 -1
  36. package/esm/model-loader.js +3 -3
  37. package/esm/model-loader.js.map +1 -1
  38. package/esm/node-ref.d.ts +1 -1
  39. package/esm/node-ref.d.ts.map +1 -1
  40. package/esm/object-ref.d.ts +2 -2
  41. package/esm/object-ref.d.ts.map +1 -1
  42. package/esm/schema-builder.js +8 -8
  43. package/esm/schema-builder.js.map +1 -1
  44. package/esm/types.d.ts +35 -31
  45. package/esm/types.d.ts.map +1 -1
  46. package/esm/types.js.map +1 -1
  47. package/esm/utils/config.d.ts.map +1 -1
  48. package/esm/utils/config.js +17 -21
  49. package/esm/utils/config.js.map +1 -1
  50. package/esm/utils/cursors.d.ts +3 -3
  51. package/esm/utils/cursors.d.ts.map +1 -1
  52. package/esm/utils/cursors.js +17 -14
  53. package/esm/utils/cursors.js.map +1 -1
  54. package/esm/utils/selections.d.ts +1 -1
  55. package/esm/utils/selections.d.ts.map +1 -1
  56. package/esm/utils/selections.js +6 -13
  57. package/esm/utils/selections.js.map +1 -1
  58. package/lib/connection-helpers.js +2 -2
  59. package/lib/connection-helpers.js.map +1 -1
  60. package/lib/drizzle-field-builder.js +12 -18
  61. package/lib/drizzle-field-builder.js.map +1 -1
  62. package/lib/model-loader.js +2 -2
  63. package/lib/model-loader.js.map +1 -1
  64. package/lib/schema-builder.js +8 -8
  65. package/lib/schema-builder.js.map +1 -1
  66. package/lib/types.js.map +1 -1
  67. package/lib/utils/config.js +16 -20
  68. package/lib/utils/config.js.map +1 -1
  69. package/lib/utils/cursors.js +17 -14
  70. package/lib/utils/cursors.js.map +1 -1
  71. package/lib/utils/selections.js +6 -12
  72. package/lib/utils/selections.js.map +1 -1
  73. package/package.json +7 -7
  74. package/src/connection-helpers.ts +13 -12
  75. package/src/drizzle-field-builder.ts +14 -30
  76. package/src/global-types.ts +59 -85
  77. package/src/interface-ref.ts +3 -3
  78. package/src/model-loader.ts +4 -3
  79. package/src/node-ref.ts +1 -1
  80. package/src/object-ref.ts +2 -2
  81. package/src/schema-builder.ts +8 -8
  82. package/src/types.ts +45 -47
  83. package/src/utils/config.ts +21 -32
  84. package/src/utils/cursors.ts +31 -18
  85. package/src/utils/selections.ts +7 -17
@@ -2,7 +2,6 @@ import type {
2
2
  FieldKind,
3
3
  FieldMap,
4
4
  FieldNullability,
5
- FieldRef,
6
5
  InputFieldMap,
7
6
  InterfaceParam,
8
7
  NormalizeArgs,
@@ -13,10 +12,8 @@ import type {
13
12
  TypeParam,
14
13
  } from '@pothos/core';
15
14
  import type {
16
- AnyRelations,
17
15
  BuildQueryResult,
18
16
  DBQueryConfig,
19
- ExtractTablesWithRelations,
20
17
  TableRelationalConfig,
21
18
  TablesRelationalConfig,
22
19
  } from 'drizzle-orm';
@@ -55,29 +52,23 @@ declare global {
55
52
  }
56
53
 
57
54
  export interface UserSchemaTypes {
58
- DrizzleRelations: AnyRelations;
59
- DrizzleRelationsConfig: TablesRelationalConfig;
55
+ DrizzleRelations: TablesRelationalConfig;
60
56
  }
61
57
 
62
58
  export interface ExtendDefaultTypes<PartialTypes extends Partial<UserSchemaTypes>> {
63
59
  DrizzleRelations: PartialTypes['DrizzleRelations'] & {};
64
- DrizzleRelationsConfig: ExtractTablesWithRelations<PartialTypes['DrizzleRelations'] & {}>;
65
60
  }
66
61
 
67
62
  export interface SchemaBuilder<Types extends SchemaTypes> {
68
63
  drizzleObject: <
69
64
  const Interfaces extends InterfaceParam<Types>[],
70
- Table extends keyof Types['DrizzleRelations']['tables'],
65
+ Table extends keyof Types['DrizzleRelations'],
71
66
  Selection extends
72
- | DBQueryConfig<
73
- 'one',
74
- Types['DrizzleRelationsConfig'],
75
- Types['DrizzleRelationsConfig'][Table]
76
- >
67
+ | DBQueryConfig<'one', Types['DrizzleRelations'], Types['DrizzleRelations'][Table]>
77
68
  | true,
78
69
  Shape = BuildQueryResult<
79
- Types['DrizzleRelationsConfig'],
80
- Types['DrizzleRelationsConfig'][Table],
70
+ Types['DrizzleRelations'],
71
+ Types['DrizzleRelations'][Table],
81
72
  true extends Selection ? true : Selection & { columns: {} }
82
73
  >,
83
74
  >(
@@ -87,17 +78,13 @@ declare global {
87
78
 
88
79
  drizzleInterface: <
89
80
  const Interfaces extends InterfaceParam<Types>[],
90
- Table extends keyof Types['DrizzleRelationsConfig'],
81
+ Table extends keyof Types['DrizzleRelations'],
91
82
  Selection extends
92
- | DBQueryConfig<
93
- 'one',
94
- Types['DrizzleRelationsConfig'],
95
- Types['DrizzleRelationsConfig'][Table]
96
- >
83
+ | DBQueryConfig<'one', Types['DrizzleRelations'], Types['DrizzleRelations'][Table]>
97
84
  | true,
98
85
  Shape = BuildQueryResult<
99
- Types['DrizzleRelationsConfig'],
100
- Types['DrizzleRelationsConfig'][Table],
86
+ Types['DrizzleRelations'],
87
+ Types['DrizzleRelations'][Table],
101
88
  true extends Selection ? true : Selection & { columns: {} }
102
89
  >,
103
90
  >(
@@ -108,18 +95,14 @@ declare global {
108
95
  drizzleNode: 'relay' extends PluginName
109
96
  ? <
110
97
  const Interfaces extends InterfaceParam<Types>[],
111
- Table extends keyof Types['DrizzleRelationsConfig'],
98
+ Table extends keyof Types['DrizzleRelations'],
112
99
  Selection extends
113
- | DBQueryConfig<
114
- 'one',
115
- Types['DrizzleRelationsConfig'],
116
- Types['DrizzleRelationsConfig'][Table]
117
- >
100
+ | DBQueryConfig<'one', Types['DrizzleRelations'], Types['DrizzleRelations'][Table]>
118
101
  | true,
119
102
  IDColumns,
120
103
  Shape = BuildQueryResult<
121
- Types['DrizzleRelationsConfig'],
122
- Types['DrizzleRelationsConfig'][Table],
104
+ Types['DrizzleRelations'],
105
+ Types['DrizzleRelations'][Table],
123
106
  true extends Selection ? true : Selection & { columns: {} }
124
107
  >,
125
108
  >(
@@ -129,17 +112,17 @@ declare global {
129
112
  : '@pothos/plugin-relay is required to use this method';
130
113
 
131
114
  drizzleObjectField: <
132
- Type extends DrizzleObjectRef<Types> | keyof Types['DrizzleRelationsConfig'],
115
+ Type extends DrizzleObjectRef<Types> | keyof Types['DrizzleRelations'],
133
116
  TableConfig extends TableRelationalConfig = Type extends DrizzleObjectRef<Types>
134
117
  ? Type[typeof drizzleTableKey]
135
- : Types['DrizzleRelationsConfig'][Type & keyof Types['DrizzleRelationsConfig']],
118
+ : Types['DrizzleRelations'][Type & keyof Types['DrizzleRelations']],
136
119
  Shape extends {} = Type extends DrizzleObjectRef<
137
120
  Types,
138
- keyof Types['DrizzleRelationsConfig'],
121
+ keyof Types['DrizzleRelations'],
139
122
  infer S
140
123
  >
141
- ? S & { [drizzleTableName]?: TableConfig['tsName'] }
142
- : BuildQueryResult<Types['DrizzleRelationsConfig'], TableConfig, true> & {
124
+ ? S & { [drizzleTableName]?: TableConfig['name'] }
125
+ : BuildQueryResult<Types['DrizzleRelations'], TableConfig, true> & {
143
126
  [drizzleTableName]?: Type;
144
127
  },
145
128
  >(
@@ -149,17 +132,17 @@ declare global {
149
132
  ) => void;
150
133
 
151
134
  drizzleInterfaceField: <
152
- Type extends DrizzleInterfaceRef<Types> | keyof Types['DrizzleRelationsConfig'],
135
+ Type extends DrizzleInterfaceRef<Types> | keyof Types['DrizzleRelations'],
153
136
  TableConfig extends TableRelationalConfig = Type extends DrizzleInterfaceRef<Types>
154
137
  ? Type[typeof drizzleTableKey]
155
- : Types['DrizzleRelationsConfig'][Type & keyof Types['DrizzleRelationsConfig']],
138
+ : Types['DrizzleRelations'][Type & keyof Types['DrizzleRelations']],
156
139
  Shape extends {} = Type extends DrizzleInterfaceRef<
157
140
  Types,
158
- keyof Types['DrizzleRelationsConfig'],
141
+ keyof Types['DrizzleRelations'],
159
142
  infer S
160
143
  >
161
- ? S & { [drizzleTableName]?: TableConfig['tsName'] }
162
- : BuildQueryResult<Types['DrizzleRelationsConfig'], TableConfig, true> & {
144
+ ? S & { [drizzleTableName]?: TableConfig['name'] }
145
+ : BuildQueryResult<Types['DrizzleRelations'], TableConfig, true> & {
163
146
  [drizzleTableName]?: Type;
164
147
  },
165
148
  >(
@@ -169,17 +152,17 @@ declare global {
169
152
  ) => void;
170
153
 
171
154
  drizzleObjectFields: <
172
- Type extends DrizzleObjectRef<Types> | keyof Types['DrizzleRelationsConfig'],
155
+ Type extends DrizzleObjectRef<Types> | keyof Types['DrizzleRelations'],
173
156
  TableConfig extends TableRelationalConfig = Type extends DrizzleObjectRef<Types>
174
157
  ? Type[typeof drizzleTableKey]
175
- : Types['DrizzleRelationsConfig'][Type & keyof Types['DrizzleRelationsConfig']],
158
+ : Types['DrizzleRelations'][Type & keyof Types['DrizzleRelations']],
176
159
  Shape extends {} = Type extends DrizzleObjectRef<
177
160
  Types,
178
- keyof Types['DrizzleRelationsConfig'],
161
+ keyof Types['DrizzleRelations'],
179
162
  infer S
180
163
  >
181
- ? S & { [drizzleTableName]?: TableConfig['tsName'] }
182
- : BuildQueryResult<Types['DrizzleRelationsConfig'], TableConfig, true> & {
164
+ ? S & { [drizzleTableName]?: TableConfig['name'] }
165
+ : BuildQueryResult<Types['DrizzleRelations'], TableConfig, true> & {
183
166
  [drizzleTableName]?: Type;
184
167
  },
185
168
  >(
@@ -188,17 +171,17 @@ declare global {
188
171
  ) => void;
189
172
 
190
173
  drizzleInterfaceFields: <
191
- Type extends DrizzleInterfaceRef<Types> | keyof Types['DrizzleRelationsConfig'],
174
+ Type extends DrizzleInterfaceRef<Types> | keyof Types['DrizzleRelations'],
192
175
  TableConfig extends TableRelationalConfig = Type extends DrizzleInterfaceRef<Types>
193
176
  ? Type[typeof drizzleTableKey]
194
- : Types['DrizzleRelationsConfig'][Type & keyof Types['DrizzleRelationsConfig']],
177
+ : Types['DrizzleRelations'][Type & keyof Types['DrizzleRelations']],
195
178
  Shape extends {} = Type extends DrizzleInterfaceRef<
196
179
  Types,
197
- keyof Types['DrizzleRelationsConfig'],
180
+ keyof Types['DrizzleRelations'],
198
181
  infer S
199
182
  >
200
- ? S & { [drizzleTableName]?: TableConfig['tsName'] }
201
- : BuildQueryResult<Types['DrizzleRelationsConfig'], TableConfig, true> & {
183
+ ? S & { [drizzleTableName]?: TableConfig['name'] }
184
+ : BuildQueryResult<Types['DrizzleRelations'], TableConfig, true> & {
202
185
  [drizzleTableName]?: Type;
203
186
  },
204
187
  >(
@@ -207,7 +190,7 @@ declare global {
207
190
  ) => void;
208
191
 
209
192
  // drizzleGraphQLOrderBy: 'addGraphQL' extends PluginName
210
- // ? <Table extends keyof Types['DrizzleRelationsConfig']>(
193
+ // ? <Table extends keyof Types['DrizzleRelations']>(
211
194
  // table: Table,
212
195
  // type: GraphQLInputObjectType,
213
196
  // ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
@@ -215,7 +198,7 @@ declare global {
215
198
  // : '@pothos/plugin-add-graphql is required to use this method';
216
199
 
217
200
  // drizzleGraphQLFilters: 'addGraphQL' extends PluginName
218
- // ? <Table extends keyof Types['DrizzleRelationsConfig']>(
201
+ // ? <Table extends keyof Types['DrizzleRelations']>(
219
202
  // table: Table,
220
203
  // type: GraphQLInputObjectType,
221
204
  // ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
@@ -223,7 +206,7 @@ declare global {
223
206
  // : '@pothos/plugin-add-graphql is required to use this method';
224
207
 
225
208
  // drizzleGraphQLInsert: 'addGraphQL' extends PluginName
226
- // ? <Table extends keyof Types['DrizzleRelationsConfig']>(
209
+ // ? <Table extends keyof Types['DrizzleRelations']>(
227
210
  // table: Table,
228
211
  // type: GraphQLInputObjectType,
229
212
  // ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
@@ -231,7 +214,7 @@ declare global {
231
214
  // : '@pothos/plugin-add-graphql is required to use this method';
232
215
 
233
216
  // drizzleGraphQLUpdate: 'addGraphQL' extends PluginName
234
- // ? <Table extends keyof Types['DrizzleRelationsConfig']>(
217
+ // ? <Table extends keyof Types['DrizzleRelations']>(
235
218
  // table: Table,
236
219
  // type: GraphQLInputObjectType,
237
220
  // ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
@@ -271,8 +254,8 @@ declare global {
271
254
  drizzleField: <
272
255
  Args extends InputFieldMap,
273
256
  Param extends
274
- | keyof Types['DrizzleRelationsConfig']
275
- | [keyof Types['DrizzleRelationsConfig']]
257
+ | keyof Types['DrizzleRelations']
258
+ | [keyof Types['DrizzleRelations']]
276
259
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
277
260
  | DrizzleRef<any>
278
261
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
@@ -281,16 +264,16 @@ declare global {
281
264
  ResolveShape,
282
265
  ResolveReturnShape,
283
266
  Table extends
284
- keyof Types['DrizzleRelationsConfig'] = Param extends keyof Types['DrizzleRelationsConfig']
267
+ keyof Types['DrizzleRelations'] = Param extends keyof Types['DrizzleRelations']
285
268
  ? Param
286
- : Param extends [keyof Types['DrizzleRelationsConfig']]
269
+ : Param extends [keyof Types['DrizzleRelations']]
287
270
  ? Param[0]
288
271
  : // biome-ignore lint/suspicious/noExplicitAny: this is fine
289
272
  Param extends DrizzleRef<any, infer T>
290
- ? T & keyof Types['DrizzleRelationsConfig']
273
+ ? T & keyof Types['DrizzleRelations']
291
274
  : // biome-ignore lint/suspicious/noExplicitAny: this is fine
292
275
  Param extends [DrizzleRef<any, infer T>]
293
- ? T & keyof Types['DrizzleRelationsConfig']
276
+ ? T & keyof Types['DrizzleRelations']
294
277
  : never,
295
278
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
296
279
  Type extends TypeParam<Types> = Param extends DrizzleRef<any> | [DrizzleRef<any>]
@@ -300,19 +283,15 @@ declare global {
300
283
  ObjectRef<
301
284
  Types,
302
285
  BuildQueryResult<
303
- Types['DrizzleRelationsConfig'],
304
- Types['DrizzleRelationsConfig'][Table],
286
+ Types['DrizzleRelations'],
287
+ Types['DrizzleRelations'][Table],
305
288
  true
306
289
  >
307
290
  >,
308
291
  ]
309
292
  : ObjectRef<
310
293
  Types,
311
- BuildQueryResult<
312
- Types['DrizzleRelationsConfig'],
313
- Types['DrizzleRelationsConfig'][Table],
314
- true
315
- >
294
+ BuildQueryResult<Types['DrizzleRelations'], Types['DrizzleRelations'][Table], true>
316
295
  >,
317
296
  >(
318
297
  options: DrizzleFieldOptions<
@@ -331,21 +310,20 @@ declare global {
331
310
  drizzleConnection: 'relay' extends PluginName
332
311
  ? <
333
312
  Type extends // biome-ignore lint/suspicious/noExplicitAny: this is fine
334
- | DrizzleRef<any, keyof Types['DrizzleRelationsConfig']>
335
- | keyof Types['DrizzleRelationsConfig'],
313
+ DrizzleRef<any, keyof Types['DrizzleRelations']> | keyof Types['DrizzleRelations'],
336
314
  Nullable extends boolean,
337
315
  ResolveReturnShape,
338
316
  Args extends InputFieldMap = {},
339
317
  Shape = Type extends DrizzleRef<
340
318
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
341
319
  any,
342
- keyof Types['DrizzleRelationsConfig'],
320
+ keyof Types['DrizzleRelations'],
343
321
  infer S
344
322
  >
345
323
  ? S
346
324
  : BuildQueryResult<
347
- Types['DrizzleRelationsConfig'],
348
- Types['DrizzleRelationsConfig'][Type & keyof Types['DrizzleRelationsConfig']],
325
+ Types['DrizzleRelations'],
326
+ Types['DrizzleRelations'][Type & keyof Types['DrizzleRelations']],
349
327
  true
350
328
  >,
351
329
  const ConnectionInterfaces extends InterfaceParam<Types>[] = [],
@@ -356,9 +334,9 @@ declare global {
356
334
  ParentShape,
357
335
  Type,
358
336
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
359
- Types['DrizzleRelationsConfig'][Type extends DrizzleRef<any, infer K>
337
+ Types['DrizzleRelations'][Type extends DrizzleRef<any, infer K>
360
338
  ? K
361
- : Type & keyof Types['DrizzleRelationsConfig']],
339
+ : Type & keyof Types['DrizzleRelations']],
362
340
  ObjectRef<Types, Shape>,
363
341
  Nullable,
364
342
  Args,
@@ -403,8 +381,8 @@ declare global {
403
381
  drizzleFieldWithInput: 'withInput' extends PluginName
404
382
  ? <
405
383
  Param extends
406
- | keyof Types['DrizzleRelationsConfig']
407
- | [keyof Types['DrizzleRelationsConfig']]
384
+ | keyof Types['DrizzleRelations']
385
+ | [keyof Types['DrizzleRelations']]
408
386
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
409
387
  | DrizzleRef<any>
410
388
  // biome-ignore lint/suspicious/noExplicitAny: this is fine
@@ -417,24 +395,20 @@ declare global {
417
395
  Args extends InputFieldMap = {},
418
396
  InputName extends string = 'input',
419
397
  Table extends
420
- keyof Types['DrizzleRelationsConfig'] = Param extends keyof Types['DrizzleRelationsConfig']
398
+ keyof Types['DrizzleRelations'] = Param extends keyof Types['DrizzleRelations']
421
399
  ? Param
422
- : Param extends [keyof Types['DrizzleRelationsConfig']]
400
+ : Param extends [keyof Types['DrizzleRelations']]
423
401
  ? Param[0]
424
402
  : // biome-ignore lint/suspicious/noExplicitAny: this is fine
425
403
  Param extends DrizzleRef<any, infer T>
426
- ? T & keyof Types['DrizzleRelationsConfig']
404
+ ? T & keyof Types['DrizzleRelations']
427
405
  : // biome-ignore lint/suspicious/noExplicitAny: this is fine
428
406
  Param extends [DrizzleRef<any, infer T>]
429
- ? T & keyof Types['DrizzleRelationsConfig']
407
+ ? T & keyof Types['DrizzleRelations']
430
408
  : never,
431
409
  Type extends TypeParam<Types> = ObjectRef<
432
410
  Types,
433
- BuildQueryResult<
434
- Types['DrizzleRelationsConfig'],
435
- Types['DrizzleRelationsConfig'][Table],
436
- true
437
- >
411
+ BuildQueryResult<Types['DrizzleRelations'], Types['DrizzleRelations'][Table], true>
438
412
  >,
439
413
  >(
440
414
  options: DrizzleFieldWithInputOptions<
@@ -4,7 +4,7 @@ import { type DrizzleObjectRef, drizzleTableKey } from './object-ref';
4
4
 
5
5
  export type DrizzleRef<
6
6
  Types extends SchemaTypes,
7
- Table extends keyof Types['DrizzleRelationsConfig'] = keyof Types['DrizzleRelationsConfig'],
7
+ Table extends keyof Types['DrizzleRelations'] = keyof Types['DrizzleRelations'],
8
8
  T = {},
9
9
  > =
10
10
  | DrizzleInterfaceRef<Types, Table, T>
@@ -13,10 +13,10 @@ export type DrizzleRef<
13
13
 
14
14
  export class DrizzleInterfaceRef<
15
15
  Types extends SchemaTypes,
16
- Table extends keyof Types['DrizzleRelationsConfig'] = keyof Types['DrizzleRelationsConfig'],
16
+ Table extends keyof Types['DrizzleRelations'] = keyof Types['DrizzleRelations'],
17
17
  T = {},
18
18
  > extends InterfaceRef<Types, T> {
19
- [drizzleTableKey]!: Types['DrizzleRelationsConfig'][Table];
19
+ [drizzleTableKey]!: Types['DrizzleRelations'][Table];
20
20
 
21
21
  tableName: string;
22
22
 
@@ -2,6 +2,7 @@ import { createContextCache, type SchemaTypes } from '@pothos/core';
2
2
  import {
3
3
  type AnyTable,
4
4
  type Column,
5
+ getTableColumns,
5
6
  inArray,
6
7
  type SQL,
7
8
  sql,
@@ -54,16 +55,16 @@ export class ModelLoader {
54
55
  this.builder = builder;
55
56
  this.modelName = modelName;
56
57
  this.config = getSchemaConfig(builder);
57
- this.table = this.config.relations.tablesConfig[modelName];
58
+ this.table = this.config.relations[modelName];
58
59
  this.primaryKey = this.config.getPrimaryKey(modelName);
59
60
  this.columns = columns ?? this.primaryKey;
60
61
  this.selectSQL = (table) => {
61
62
  const columns = this.columns.map((column) =>
62
- Object.values(table).find(
63
+ Object.values(getTableColumns(table)).find(
63
64
  (tblColumn) => 'columnType' in tblColumn && tblColumn.name === column.name,
64
65
  ),
65
66
  );
66
- return columns.length > 1 ? sql`(${sql.join(columns, sql`, `)})` : columns[0].getSQL();
67
+ return columns.length > 1 ? sql`(${sql.join(columns, sql`, `)})` : columns[0]!.getSQL();
67
68
  };
68
69
  }
69
70
 
package/src/node-ref.ts CHANGED
@@ -5,7 +5,7 @@ export const relayIDShapeKey = Symbol.for('Pothos.relayIDShapeKey');
5
5
 
6
6
  export class DrizzleNodeRef<
7
7
  Types extends SchemaTypes,
8
- Table extends keyof Types['DrizzleRelationsConfig'] = keyof Types['DrizzleRelationsConfig'],
8
+ Table extends keyof Types['DrizzleRelations'] = keyof Types['DrizzleRelations'],
9
9
  T = {},
10
10
  IDShape = string,
11
11
  > extends DrizzleObjectRef<Types, Table, T> {
package/src/object-ref.ts CHANGED
@@ -11,10 +11,10 @@ export const drizzleTableKey = Symbol.for('Pothos.drizzleTableKey');
11
11
 
12
12
  export class DrizzleObjectRef<
13
13
  Types extends SchemaTypes,
14
- Table extends keyof Types['DrizzleRelationsConfig'] = keyof Types['DrizzleRelationsConfig'],
14
+ Table extends keyof Types['DrizzleRelations'] = keyof Types['DrizzleRelations'],
15
15
  T = {},
16
16
  > extends ObjectRef<Types, T> {
17
- [drizzleTableKey]!: Types['DrizzleRelationsConfig'][Table];
17
+ [drizzleTableKey]!: Types['DrizzleRelations'][Table];
18
18
 
19
19
  [abstractReturnShapeKey]!: WithBrand<T>;
20
20
 
@@ -36,7 +36,7 @@ schemaBuilderProto.drizzleObject = function drizzleObject(table, { select, field
36
36
  extensions: {
37
37
  ...options.extensions,
38
38
  pothosDrizzleModel: table,
39
- pothosDrizzleTable: getSchemaConfig(this).relations.tablesConfig[table],
39
+ pothosDrizzleTable: getSchemaConfig(this).relations[table],
40
40
  pothosDrizzleSelect:
41
41
  typeof select === 'object' ? { columns: {}, ...select } : (select ?? true),
42
42
  pothosDrizzleLoader: ModelLoader.forModel(table, this),
@@ -65,7 +65,7 @@ schemaBuilderProto.drizzleInterface = function drizzleInterface(
65
65
  extensions: {
66
66
  ...options.extensions,
67
67
  pothosDrizzleModel: table,
68
- pothosDrizzleTable: getSchemaConfig(this).relations.tablesConfig[table],
68
+ pothosDrizzleTable: getSchemaConfig(this).relations[table],
69
69
  pothosDrizzleSelect:
70
70
  typeof select === 'object' ? { columns: {}, ...select } : (select ?? true),
71
71
  pothosDrizzleLoader: ModelLoader.forModel(table, this),
@@ -99,8 +99,8 @@ schemaBuilderProto.drizzleNode = function drizzleNode(
99
99
  >,
100
100
  ) {
101
101
  const schemaConfig = getSchemaConfig(this);
102
- const tableConfig = schemaConfig.relations.tablesConfig[table];
103
- const idColumn = typeof column === 'function' ? column(tableConfig.columns) : column;
102
+ const tableConfig = schemaConfig.relations[table];
103
+ const idColumn = typeof column === 'function' ? column(tableConfig.table) : column;
104
104
  const idColumns = Array.isArray(idColumn) ? idColumn : [idColumn];
105
105
  const interfaceRef = this.nodeInterfaceRef?.();
106
106
  const resolve = getIDSerializer(idColumns, schemaConfig);
@@ -232,7 +232,7 @@ schemaBuilderProto.drizzleInterfaceFields = function drizzleInterfaceFields(type
232
232
  // drizzleGraphQL: {
233
233
  // inputType: 'orderBy',
234
234
  // table,
235
- // tableConfig: getSchemaConfig(this).relations.tablesConfig[table],
235
+ // tableConfig: getSchemaConfig(this).relations[table],
236
236
  // } satisfies DrizzleGraphQLInputExtensions,
237
237
  // },
238
238
  // });
@@ -258,7 +258,7 @@ schemaBuilderProto.drizzleInterfaceFields = function drizzleInterfaceFields(type
258
258
  // drizzleGraphQL: {
259
259
  // inputType: 'filters',
260
260
  // table,
261
- // tableConfig: getSchemaConfig(this).relations.tablesConfig[table],
261
+ // tableConfig: getSchemaConfig(this).relations[table],
262
262
  // } satisfies DrizzleGraphQLInputExtensions,
263
263
  // },
264
264
  // });
@@ -284,7 +284,7 @@ schemaBuilderProto.drizzleInterfaceFields = function drizzleInterfaceFields(type
284
284
  // drizzleGraphQL: {
285
285
  // inputType: 'insert',
286
286
  // table,
287
- // tableConfig: getSchemaConfig(this).relations.tablesConfig[table],
287
+ // tableConfig: getSchemaConfig(this).relations[table],
288
288
  // } satisfies DrizzleGraphQLInputExtensions,
289
289
  // },
290
290
  // });
@@ -310,7 +310,7 @@ schemaBuilderProto.drizzleInterfaceFields = function drizzleInterfaceFields(type
310
310
  // drizzleGraphQL: {
311
311
  // inputType: 'update',
312
312
  // table,
313
- // tableConfig: getSchemaConfig(this).relations.tablesConfig[table],
313
+ // tableConfig: getSchemaConfig(this).relations[table],
314
314
  // } satisfies DrizzleGraphQLInputExtensions,
315
315
  // },
316
316
  // });