@pothos/plugin-drizzle 0.0.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 (179) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +6 -0
  3. package/README.md +437 -0
  4. package/TODO.md +21 -0
  5. package/drizzle/meta/_journal.json +1 -0
  6. package/drizzle.config.ts +10 -0
  7. package/dts/drizzle-field-builder.d.ts +124 -0
  8. package/dts/drizzle-field-builder.d.ts.map +1 -0
  9. package/dts/field-builder.d.ts +2 -0
  10. package/dts/field-builder.d.ts.map +1 -0
  11. package/dts/global-types.d.ts +92 -0
  12. package/dts/global-types.d.ts.map +1 -0
  13. package/dts/index.d.ts +13 -0
  14. package/dts/index.d.ts.map +1 -0
  15. package/dts/interface-ref.d.ts +9 -0
  16. package/dts/interface-ref.d.ts.map +1 -0
  17. package/dts/model-loader.d.ts +44 -0
  18. package/dts/model-loader.d.ts.map +1 -0
  19. package/dts/node-ref.d.ts +5 -0
  20. package/dts/node-ref.d.ts.map +1 -0
  21. package/dts/object-ref.d.ts +14 -0
  22. package/dts/object-ref.d.ts.map +1 -0
  23. package/dts/schema-builder.d.ts +2 -0
  24. package/dts/schema-builder.d.ts.map +1 -0
  25. package/dts/types.d.ts +147 -0
  26. package/dts/types.d.ts.map +1 -0
  27. package/dts/utils/config.d.ts +7 -0
  28. package/dts/utils/config.d.ts.map +1 -0
  29. package/dts/utils/cursors.d.ts +58 -0
  30. package/dts/utils/cursors.d.ts.map +1 -0
  31. package/dts/utils/deep-equal.d.ts +2 -0
  32. package/dts/utils/deep-equal.d.ts.map +1 -0
  33. package/dts/utils/drizzle-graphql.d.ts +18 -0
  34. package/dts/utils/drizzle-graphql.d.ts.map +1 -0
  35. package/dts/utils/loader-map.d.ts +11 -0
  36. package/dts/utils/loader-map.d.ts.map +1 -0
  37. package/dts/utils/map-query.d.ts +30 -0
  38. package/dts/utils/map-query.d.ts.map +1 -0
  39. package/dts/utils/refs.d.ts +5 -0
  40. package/dts/utils/refs.d.ts.map +1 -0
  41. package/dts/utils/selections.d.ts +22 -0
  42. package/dts/utils/selections.d.ts.map +1 -0
  43. package/dts/utils/usage.d.ts +5 -0
  44. package/dts/utils/usage.d.ts.map +1 -0
  45. package/esm/drizzle-field-builder.d.ts +216 -0
  46. package/esm/drizzle-field-builder.d.ts.map +1 -0
  47. package/esm/field-builder.d.ts +2 -0
  48. package/esm/field-builder.d.ts.map +1 -0
  49. package/esm/global-types.d.ts +124 -0
  50. package/esm/global-types.d.ts.map +1 -0
  51. package/esm/index.d.ts +13 -0
  52. package/esm/index.d.ts.map +1 -0
  53. package/esm/interface-ref.d.ts +9 -0
  54. package/esm/interface-ref.d.ts.map +1 -0
  55. package/esm/model-loader.d.ts +45 -0
  56. package/esm/model-loader.d.ts.map +1 -0
  57. package/esm/node-ref.d.ts +5 -0
  58. package/esm/node-ref.d.ts.map +1 -0
  59. package/esm/object-ref.d.ts +14 -0
  60. package/esm/object-ref.d.ts.map +1 -0
  61. package/esm/package.json +3 -0
  62. package/esm/schema-builder.d.ts +2 -0
  63. package/esm/schema-builder.d.ts.map +1 -0
  64. package/esm/src/drizzle-field-builder.js +215 -0
  65. package/esm/src/drizzle-field-builder.js.map +1 -0
  66. package/esm/src/field-builder.js +77 -0
  67. package/esm/src/field-builder.js.map +1 -0
  68. package/esm/src/global-types.js +2 -0
  69. package/esm/src/global-types.js.map +1 -0
  70. package/esm/src/index.js +107 -0
  71. package/esm/src/index.js.map +1 -0
  72. package/esm/src/interface-ref.js +26 -0
  73. package/esm/src/interface-ref.js.map +1 -0
  74. package/esm/src/model-loader.js +168 -0
  75. package/esm/src/model-loader.js.map +1 -0
  76. package/esm/src/node-ref.js +4 -0
  77. package/esm/src/node-ref.js.map +1 -0
  78. package/esm/src/object-ref.js +38 -0
  79. package/esm/src/object-ref.js.map +1 -0
  80. package/esm/src/schema-builder.js +190 -0
  81. package/esm/src/schema-builder.js.map +1 -0
  82. package/esm/src/types.js +2 -0
  83. package/esm/src/types.js.map +1 -0
  84. package/esm/src/utils/config.js +15 -0
  85. package/esm/src/utils/config.js.map +1 -0
  86. package/esm/src/utils/cursors.js +316 -0
  87. package/esm/src/utils/cursors.js.map +1 -0
  88. package/esm/src/utils/deep-equal.js +44 -0
  89. package/esm/src/utils/deep-equal.js.map +1 -0
  90. package/esm/src/utils/drizzle-graphql.js +176 -0
  91. package/esm/src/utils/drizzle-graphql.js.map +1 -0
  92. package/esm/src/utils/loader-map.js +35 -0
  93. package/esm/src/utils/loader-map.js.map +1 -0
  94. package/esm/src/utils/map-query.js +284 -0
  95. package/esm/src/utils/map-query.js.map +1 -0
  96. package/esm/src/utils/refs.js +14 -0
  97. package/esm/src/utils/refs.js.map +1 -0
  98. package/esm/src/utils/selections.js +136 -0
  99. package/esm/src/utils/selections.js.map +1 -0
  100. package/esm/src/utils/usage.js +59 -0
  101. package/esm/src/utils/usage.js.map +1 -0
  102. package/esm/types.d.ts +161 -0
  103. package/esm/types.d.ts.map +1 -0
  104. package/esm/utils/config.d.ts +7 -0
  105. package/esm/utils/config.d.ts.map +1 -0
  106. package/esm/utils/cursors.d.ts +58 -0
  107. package/esm/utils/cursors.d.ts.map +1 -0
  108. package/esm/utils/deep-equal.d.ts +2 -0
  109. package/esm/utils/deep-equal.d.ts.map +1 -0
  110. package/esm/utils/drizzle-graphql.d.ts +18 -0
  111. package/esm/utils/drizzle-graphql.d.ts.map +1 -0
  112. package/esm/utils/loader-map.d.ts +11 -0
  113. package/esm/utils/loader-map.d.ts.map +1 -0
  114. package/esm/utils/map-query.d.ts +30 -0
  115. package/esm/utils/map-query.d.ts.map +1 -0
  116. package/esm/utils/refs.d.ts +5 -0
  117. package/esm/utils/refs.d.ts.map +1 -0
  118. package/esm/utils/selections.d.ts +22 -0
  119. package/esm/utils/selections.d.ts.map +1 -0
  120. package/esm/utils/usage.d.ts +5 -0
  121. package/esm/utils/usage.d.ts.map +1 -0
  122. package/lib/src/drizzle-field-builder.js +225 -0
  123. package/lib/src/drizzle-field-builder.js.map +1 -0
  124. package/lib/src/field-builder.js +82 -0
  125. package/lib/src/field-builder.js.map +1 -0
  126. package/lib/src/global-types.js +6 -0
  127. package/lib/src/global-types.js.map +1 -0
  128. package/lib/src/index.js +180 -0
  129. package/lib/src/index.js.map +1 -0
  130. package/lib/src/interface-ref.js +36 -0
  131. package/lib/src/interface-ref.js.map +1 -0
  132. package/lib/src/model-loader.js +176 -0
  133. package/lib/src/model-loader.js.map +1 -0
  134. package/lib/src/node-ref.js +15 -0
  135. package/lib/src/node-ref.js.map +1 -0
  136. package/lib/src/object-ref.js +56 -0
  137. package/lib/src/object-ref.js.map +1 -0
  138. package/lib/src/schema-builder.js +236 -0
  139. package/lib/src/schema-builder.js.map +1 -0
  140. package/lib/src/types.js +13 -0
  141. package/lib/src/types.js.map +1 -0
  142. package/lib/src/utils/config.js +26 -0
  143. package/lib/src/utils/config.js.map +1 -0
  144. package/lib/src/utils/cursors.js +362 -0
  145. package/lib/src/utils/cursors.js.map +1 -0
  146. package/lib/src/utils/deep-equal.js +55 -0
  147. package/lib/src/utils/deep-equal.js.map +1 -0
  148. package/lib/src/utils/drizzle-graphql.js +192 -0
  149. package/lib/src/utils/drizzle-graphql.js.map +1 -0
  150. package/lib/src/utils/loader-map.js +57 -0
  151. package/lib/src/utils/loader-map.js.map +1 -0
  152. package/lib/src/utils/map-query.js +308 -0
  153. package/lib/src/utils/map-query.js.map +1 -0
  154. package/lib/src/utils/refs.js +33 -0
  155. package/lib/src/utils/refs.js.map +1 -0
  156. package/lib/src/utils/selections.js +163 -0
  157. package/lib/src/utils/selections.js.map +1 -0
  158. package/lib/src/utils/usage.js +84 -0
  159. package/lib/src/utils/usage.js.map +1 -0
  160. package/package.json +66 -0
  161. package/src/drizzle-field-builder.ts +500 -0
  162. package/src/field-builder.ts +168 -0
  163. package/src/global-types.ts +481 -0
  164. package/src/index.ts +175 -0
  165. package/src/interface-ref.ts +24 -0
  166. package/src/model-loader.ts +235 -0
  167. package/src/node-ref.ts +8 -0
  168. package/src/object-ref.ts +51 -0
  169. package/src/schema-builder.ts +299 -0
  170. package/src/types.ts +640 -0
  171. package/src/utils/config.ts +28 -0
  172. package/src/utils/cursors.ts +446 -0
  173. package/src/utils/deep-equal.ts +58 -0
  174. package/src/utils/drizzle-graphql.ts +235 -0
  175. package/src/utils/loader-map.ts +51 -0
  176. package/src/utils/map-query.ts +582 -0
  177. package/src/utils/refs.ts +25 -0
  178. package/src/utils/selections.ts +209 -0
  179. package/src/utils/usage.ts +64 -0
@@ -0,0 +1,168 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+ import { FieldKind, ObjectRef, RootFieldBuilder, SchemaTypes } from '@pothos/core';
3
+ import { queryFromInfo } from './utils/map-query';
4
+ import { getRefFromModel } from './utils/refs';
5
+ import { FieldRef } from '@pothos/core';
6
+ import { DrizzleRef } from './interface-ref';
7
+ import { DrizzleConnectionFieldOptions } from './types';
8
+ import { TableRelationalConfig } from 'drizzle-orm';
9
+ import { resolveDrizzleCursorConnection } from './utils/cursors';
10
+ import { getSchemaConfig } from './utils/config';
11
+
12
+ const fieldBuilderProto = RootFieldBuilder.prototype as PothosSchemaTypes.RootFieldBuilder<
13
+ SchemaTypes,
14
+ unknown,
15
+ FieldKind
16
+ >;
17
+
18
+ fieldBuilderProto.drizzleField = function drizzleField({ type, resolve, ...options }) {
19
+ const modelOrRef = Array.isArray(type) ? type[0] : type;
20
+ const typeRef =
21
+ typeof modelOrRef === 'string'
22
+ ? getRefFromModel(modelOrRef, this.builder)
23
+ : (modelOrRef as ObjectRef<SchemaTypes, unknown>);
24
+ const typeParam = Array.isArray(type)
25
+ ? ([typeRef] as [ObjectRef<SchemaTypes, unknown>])
26
+ : typeRef;
27
+ return this.field({
28
+ ...(options as {}),
29
+ type: typeParam,
30
+ resolve: (parent: unknown, args: unknown, context: {}, info: GraphQLResolveInfo) => {
31
+ return resolve(
32
+ (select) =>
33
+ queryFromInfo({
34
+ config: getSchemaConfig(this.builder),
35
+ context,
36
+ select,
37
+ info,
38
+ // withUsageCheck: !!this.builder.options.drizzle?.onUnusedQuery,
39
+ }),
40
+ parent,
41
+ args as never,
42
+ context,
43
+ info,
44
+ ) as never;
45
+ },
46
+ }) as never;
47
+ };
48
+
49
+ fieldBuilderProto.drizzleFieldWithInput = function drizzleFieldWithInput(
50
+ this: typeof fieldBuilderProto,
51
+ {
52
+ type,
53
+ resolve,
54
+ ...options
55
+ }: { type: ObjectRef<SchemaTypes, unknown> | [string]; resolve: (...args: unknown[]) => unknown },
56
+ ) {
57
+ const modelOrRef = Array.isArray(type) ? type[0] : type;
58
+ const typeRef =
59
+ typeof modelOrRef === 'string'
60
+ ? getRefFromModel(modelOrRef, this.builder)
61
+ : (modelOrRef as ObjectRef<SchemaTypes, unknown>);
62
+ const typeParam = Array.isArray(type)
63
+ ? ([typeRef] as [ObjectRef<SchemaTypes, unknown>])
64
+ : typeRef;
65
+
66
+ return (
67
+ this as typeof fieldBuilderProto & { fieldWithInput: typeof fieldBuilderProto.field }
68
+ ).fieldWithInput({
69
+ ...(options as {}),
70
+ type: typeParam,
71
+ resolve: (parent: unknown, args: unknown, context: {}, info: GraphQLResolveInfo) => {
72
+ const query = queryFromInfo({
73
+ config: getSchemaConfig(this.builder),
74
+ context,
75
+ info,
76
+ // withUsageCheck: !!this.builder.options.drizzle?.onUnusedQuery,
77
+ });
78
+
79
+ return resolve(query, parent, args as never, context, info) as never;
80
+ },
81
+ });
82
+ } as never;
83
+
84
+ fieldBuilderProto.drizzleConnection = function drizzleConnection<
85
+ Type extends
86
+ | DrizzleRef<SchemaTypes, keyof SchemaTypes['DrizzleRelationSchema']>
87
+ | keyof SchemaTypes['DrizzleRelationSchema'],
88
+ Nullable extends boolean,
89
+ ResolveReturnShape,
90
+ >(
91
+ this: typeof fieldBuilderProto,
92
+ {
93
+ type,
94
+ maxSize = this.builder.options.drizzle?.maxConnectionSize,
95
+ defaultSize = this.builder.options.drizzle?.defaultConnectionSize,
96
+ resolve,
97
+ ...options
98
+ }: DrizzleConnectionFieldOptions<
99
+ SchemaTypes,
100
+ unknown,
101
+ Type,
102
+ TableRelationalConfig,
103
+ ObjectRef<SchemaTypes, {}>,
104
+ Nullable,
105
+ {},
106
+ ResolveReturnShape,
107
+ FieldKind
108
+ >,
109
+ connectionOptions: {} = {},
110
+ edgeOptions: {} = {},
111
+ ) {
112
+ const ref = typeof type === 'string' ? getRefFromModel(type, this.builder) : type;
113
+ const typeName = this.builder.configStore.getTypeConfig(ref).name;
114
+ const fieldRef = (
115
+ this as typeof fieldBuilderProto & {
116
+ connection: (...args: unknown[]) => FieldRef<SchemaTypes, unknown>;
117
+ }
118
+ ).connection(
119
+ {
120
+ ...options,
121
+ type: ref,
122
+ resolve: (
123
+ parent: unknown,
124
+ args: PothosSchemaTypes.DefaultConnectionArguments,
125
+ context: {},
126
+ info: GraphQLResolveInfo,
127
+ ) => {
128
+ const drizzleModel =
129
+ this.builder.options.drizzle.client._.schema?.[
130
+ typeof type === 'string' ? type : (ref as DrizzleRef<SchemaTypes>).tableName
131
+ ]!;
132
+
133
+ return resolveDrizzleCursorConnection(
134
+ drizzleModel,
135
+ info,
136
+ typeName,
137
+ getSchemaConfig(this.builder),
138
+ {
139
+ ctx: context,
140
+ maxSize,
141
+ defaultSize,
142
+ args,
143
+ },
144
+
145
+ (q) => {
146
+ // return checkIfQueryIsUsed(
147
+ // this.builder,
148
+ // query,
149
+ // info,
150
+ return resolve(q as never, parent, args as never, context, info) as never;
151
+ // );
152
+ },
153
+ );
154
+ },
155
+ },
156
+ connectionOptions instanceof ObjectRef
157
+ ? connectionOptions
158
+ : {
159
+ ...connectionOptions,
160
+ extensions: {
161
+ ...(connectionOptions as Record<string, {}> | undefined)?.extensions,
162
+ },
163
+ },
164
+ edgeOptions,
165
+ );
166
+
167
+ return fieldRef;
168
+ } as never;
@@ -0,0 +1,481 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /* eslint-disable @typescript-eslint/no-empty-interface */
3
+ import type {
4
+ BuildQueryResult,
5
+ DBQueryConfig,
6
+ ExtractTablesWithRelations,
7
+ SQL,
8
+ TableRelationalConfig,
9
+ } from 'drizzle-orm';
10
+ import {
11
+ FieldKind,
12
+ FieldMap,
13
+ FieldNullability,
14
+ FieldRef,
15
+ InputFieldMap,
16
+ InterfaceParam,
17
+ NormalizeArgs,
18
+ OutputType,
19
+ PluginName,
20
+ SchemaTypes,
21
+ ShapeFromTypeParam,
22
+ TypeParam,
23
+ } from '@pothos/core';
24
+ import { DrizzleObjectFieldBuilder } from './drizzle-field-builder';
25
+ import { DrizzleInterfaceRef, DrizzleRef } from './interface-ref';
26
+ import { DrizzleObjectRef, drizzleTableKey } from './object-ref';
27
+ import type {
28
+ AddGraphQLInputTypeOptions,
29
+ DrizzleConnectionFieldOptions,
30
+ DrizzleConnectionShape,
31
+ DrizzleFieldOptions,
32
+ DrizzleFieldWithInputOptions,
33
+ DrizzleInterfaceOptions,
34
+ DrizzleNodeOptions,
35
+ DrizzleObjectFieldOptions,
36
+ DrizzleObjectOptions,
37
+ DrizzlePluginOptions,
38
+ drizzleTableName,
39
+ ShapeFromConnection,
40
+ } from './types';
41
+
42
+ import type { PothosDrizzlePlugin } from '.';
43
+ import { DrizzleNodeRef } from './node-ref';
44
+ import { GraphQLInputObjectType } from 'graphql';
45
+
46
+ declare global {
47
+ export namespace PothosSchemaTypes {
48
+ export interface Plugins<Types extends SchemaTypes> {
49
+ drizzle: PothosDrizzlePlugin<Types>;
50
+ }
51
+
52
+ export interface SchemaBuilderOptions<Types extends SchemaTypes> {
53
+ drizzle: DrizzlePluginOptions<Types>;
54
+ }
55
+
56
+ export interface UserSchemaTypes {
57
+ DrizzleSchema: Record<string, unknown>;
58
+ DrizzleRelationSchema: Record<string, TableRelationalConfig>;
59
+ }
60
+
61
+ export interface ExtendDefaultTypes<PartialTypes extends Partial<UserSchemaTypes>> {
62
+ DrizzleSchema: PartialTypes['DrizzleSchema'] & {};
63
+ DrizzleRelationSchema: ExtractTablesWithRelations<PartialTypes['DrizzleSchema'] & {}>;
64
+ }
65
+
66
+ export interface SchemaBuilder<Types extends SchemaTypes> {
67
+ drizzleObject: <
68
+ Interfaces extends InterfaceParam<Types>[],
69
+ Table extends keyof Types['DrizzleRelationSchema'],
70
+ Selection extends
71
+ | DBQueryConfig<
72
+ 'one',
73
+ false,
74
+ Types['DrizzleRelationSchema'],
75
+ Types['DrizzleRelationSchema'][Table]
76
+ >
77
+ | true,
78
+ Shape = BuildQueryResult<
79
+ Types['DrizzleRelationSchema'],
80
+ Types['DrizzleRelationSchema'][Table],
81
+ Selection
82
+ >,
83
+ >(
84
+ table: Table,
85
+ options: DrizzleObjectOptions<Types, Table, Shape, Selection, Interfaces>,
86
+ ) => DrizzleObjectRef<Types, Table, Shape>;
87
+
88
+ drizzleInterface: <
89
+ Interfaces extends InterfaceParam<Types>[],
90
+ Table extends keyof Types['DrizzleRelationSchema'],
91
+ Selection extends
92
+ | DBQueryConfig<
93
+ 'one',
94
+ false,
95
+ Types['DrizzleRelationSchema'],
96
+ Types['DrizzleRelationSchema'][Table]
97
+ >
98
+ | true,
99
+ Shape = BuildQueryResult<
100
+ Types['DrizzleRelationSchema'],
101
+ Types['DrizzleRelationSchema'][Table],
102
+ Selection
103
+ >,
104
+ >(
105
+ table: Table,
106
+ options: DrizzleInterfaceOptions<Types, Table, Shape, Selection, Interfaces>,
107
+ ) => DrizzleInterfaceRef<Types, Table, Shape>;
108
+
109
+ drizzleNode: 'relay' extends PluginName
110
+ ? <
111
+ Interfaces extends InterfaceParam<Types>[],
112
+ Table extends keyof Types['DrizzleRelationSchema'],
113
+ Selection extends
114
+ | DBQueryConfig<
115
+ 'one',
116
+ false,
117
+ Types['DrizzleRelationSchema'],
118
+ Types['DrizzleRelationSchema'][Table]
119
+ >
120
+ | true,
121
+ Shape = BuildQueryResult<
122
+ Types['DrizzleRelationSchema'],
123
+ Types['DrizzleRelationSchema'][Table],
124
+ Selection
125
+ >,
126
+ >(
127
+ table: Table,
128
+ options: DrizzleNodeOptions<Types, Table, Shape, Selection, Interfaces>,
129
+ ) => DrizzleNodeRef<Types, Table, Shape>
130
+ : '@pothos/plugin-relay is required to use this method';
131
+
132
+ drizzleObjectField: <
133
+ Type extends DrizzleObjectRef<Types> | keyof Types['DrizzleRelationSchema'],
134
+ TableConfig extends TableRelationalConfig = Type extends DrizzleObjectRef<Types>
135
+ ? Type[typeof drizzleTableKey]
136
+ : Types['DrizzleRelationSchema'][Type & keyof Types['DrizzleRelationSchema']],
137
+ Shape extends {} = Type extends DrizzleObjectRef<
138
+ Types,
139
+ keyof Types['DrizzleRelationSchema'],
140
+ infer S
141
+ >
142
+ ? S & { [drizzleTableName]?: TableConfig['tsName'] }
143
+ : BuildQueryResult<Types['DrizzleRelationSchema'], TableConfig, true> & {
144
+ [drizzleTableName]?: Type;
145
+ },
146
+ >(
147
+ type: Type,
148
+ fieldName: string,
149
+ field: (t: DrizzleObjectFieldBuilder<Types, TableConfig, false, Shape>) => FieldRef<Types>,
150
+ ) => void;
151
+
152
+ drizzleInterfaceField: <
153
+ Type extends DrizzleInterfaceRef<Types> | keyof Types['DrizzleRelationSchema'],
154
+ TableConfig extends TableRelationalConfig = Type extends DrizzleObjectRef<Types>
155
+ ? Type[typeof drizzleTableKey]
156
+ : Types['DrizzleRelationSchema'][Type & keyof Types['DrizzleRelationSchema']],
157
+ Shape extends {} = Type extends DrizzleInterfaceRef<
158
+ Types,
159
+ keyof Types['DrizzleRelationSchema'],
160
+ infer S
161
+ >
162
+ ? S & { [drizzleTableName]?: TableConfig['tsName'] }
163
+ : BuildQueryResult<Types['DrizzleRelationSchema'], TableConfig, true> & {
164
+ [drizzleTableName]?: Type;
165
+ },
166
+ >(
167
+ type: Type,
168
+ fieldName: string,
169
+ field: (t: DrizzleObjectFieldBuilder<Types, TableConfig, false, Shape>) => FieldRef<Types>,
170
+ ) => void;
171
+
172
+ drizzleObjectFields: <
173
+ Type extends DrizzleObjectRef<Types> | keyof Types['DrizzleRelationSchema'],
174
+ TableConfig extends TableRelationalConfig = Type extends DrizzleObjectRef<Types>
175
+ ? Type[typeof drizzleTableKey]
176
+ : Types['DrizzleRelationSchema'][Type & keyof Types['DrizzleRelationSchema']],
177
+ Shape extends {} = Type extends DrizzleObjectRef<
178
+ Types,
179
+ keyof Types['DrizzleRelationSchema'],
180
+ infer S
181
+ >
182
+ ? S & { [drizzleTableName]?: TableConfig['tsName'] }
183
+ : BuildQueryResult<Types['DrizzleRelationSchema'], TableConfig, true> & {
184
+ [drizzleTableName]?: Type;
185
+ },
186
+ >(
187
+ type: Type,
188
+ fields: (t: DrizzleObjectFieldBuilder<Types, TableConfig, false, Shape>) => FieldMap,
189
+ ) => void;
190
+
191
+ drizzleInterfaceFields: <
192
+ Type extends DrizzleInterfaceRef<Types> | keyof Types['DrizzleRelationSchema'],
193
+ TableConfig extends TableRelationalConfig = Type extends DrizzleObjectRef<Types>
194
+ ? Type[typeof drizzleTableKey]
195
+ : Types['DrizzleRelationSchema'][Type & keyof Types['DrizzleRelationSchema']],
196
+ Shape extends {} = Type extends DrizzleInterfaceRef<
197
+ Types,
198
+ keyof Types['DrizzleRelationSchema'],
199
+ infer S
200
+ >
201
+ ? S & { [drizzleTableName]?: TableConfig['tsName'] }
202
+ : BuildQueryResult<Types['DrizzleRelationSchema'], TableConfig, true> & {
203
+ [drizzleTableName]?: Type;
204
+ },
205
+ >(
206
+ type: Type,
207
+ fields: (t: DrizzleObjectFieldBuilder<Types, TableConfig, false, Shape>) => FieldMap,
208
+ ) => void;
209
+
210
+ drizzleGraphQLOrderBy: 'addGraphQL' extends PluginName
211
+ ? <Table extends keyof Types['DrizzleRelationSchema']>(
212
+ table: Table,
213
+ type: GraphQLInputObjectType,
214
+ ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
215
+ ) => InputObjectRef<Types, SQL | SQL[]>
216
+ : '@pothos/plugin-add-graphql is required to use this method';
217
+
218
+ drizzleGraphQLFilters: 'addGraphQL' extends PluginName
219
+ ? <Table extends keyof Types['DrizzleRelationSchema']>(
220
+ table: Table,
221
+ type: GraphQLInputObjectType,
222
+ ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
223
+ ) => InputObjectRef<Types, SQL>
224
+ : '@pothos/plugin-add-graphql is required to use this method';
225
+
226
+ drizzleGraphQLInsert: 'addGraphQL' extends PluginName
227
+ ? <Table extends keyof Types['DrizzleRelationSchema']>(
228
+ table: Table,
229
+ type: GraphQLInputObjectType,
230
+ ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
231
+ ) => InputObjectRef<Types, Record<string, unknown>>
232
+ : '@pothos/plugin-add-graphql is required to use this method';
233
+
234
+ drizzleGraphQLUpdate: 'addGraphQL' extends PluginName
235
+ ? <Table extends keyof Types['DrizzleRelationSchema']>(
236
+ table: Table,
237
+ type: GraphQLInputObjectType,
238
+ ...args: NormalizeArgs<[options: AddGraphQLInputTypeOptions<Types, {}>]>
239
+ ) => InputObjectRef<Types, Record<string, unknown>>
240
+ : '@pothos/plugin-add-graphql is required to use this method';
241
+ }
242
+
243
+ export interface PothosKindToGraphQLType {
244
+ DrizzleObject: 'Object';
245
+ }
246
+
247
+ export interface FieldOptionsByKind<
248
+ Types extends SchemaTypes,
249
+ ParentShape,
250
+ Type extends TypeParam<Types>,
251
+ Nullable extends FieldNullability<Type>,
252
+ Args extends InputFieldMap,
253
+ ResolveShape,
254
+ ResolveReturnShape,
255
+ > {
256
+ DrizzleObject: DrizzleObjectFieldOptions<
257
+ Types,
258
+ ParentShape,
259
+ Type,
260
+ Nullable,
261
+ Args,
262
+ ResolveShape,
263
+ ResolveReturnShape
264
+ >;
265
+ }
266
+
267
+ export interface RootFieldBuilder<
268
+ Types extends SchemaTypes,
269
+ ParentShape,
270
+ Kind extends FieldKind = FieldKind,
271
+ > {
272
+ drizzleField: <
273
+ Args extends InputFieldMap,
274
+ Param extends
275
+ | keyof Types['DrizzleRelationSchema']
276
+ | [keyof Types['DrizzleRelationSchema']]
277
+ | DrizzleRef<any>
278
+ | [DrizzleRef<any>],
279
+ Nullable extends FieldNullability<Type>,
280
+ ResolveShape,
281
+ ResolveReturnShape,
282
+ Table extends
283
+ keyof Types['DrizzleRelationSchema'] = Param extends keyof Types['DrizzleRelationSchema']
284
+ ? Param
285
+ : Param extends [keyof Types['DrizzleRelationSchema']]
286
+ ? Param[0]
287
+ : Param extends DrizzleRef<any, infer T>
288
+ ? T & keyof Types['DrizzleRelationSchema']
289
+ : Param extends [DrizzleRef<any, infer T>]
290
+ ? T & keyof Types['DrizzleRelationSchema']
291
+ : never,
292
+ Type extends TypeParam<Types> = ObjectRef<
293
+ Types,
294
+ BuildQueryResult<
295
+ Types['DrizzleRelationSchema'],
296
+ Types['DrizzleRelationSchema'][Table],
297
+ true
298
+ >
299
+ >,
300
+ >(
301
+ options: DrizzleFieldOptions<
302
+ Types,
303
+ ParentShape,
304
+ Table,
305
+ Type,
306
+ Nullable,
307
+ Args,
308
+ Kind,
309
+ ResolveShape,
310
+ ResolveReturnShape,
311
+ Param
312
+ >,
313
+ ) => FieldRef<Types, ShapeFromTypeParam<Types, Type, Nullable>>;
314
+
315
+ drizzleConnection: 'relay' extends PluginName
316
+ ? <
317
+ Type extends
318
+ | DrizzleRef<any, keyof Types['DrizzleRelationSchema']>
319
+ | keyof Types['DrizzleRelationSchema'],
320
+ Nullable extends boolean,
321
+ ResolveReturnShape,
322
+ Args extends InputFieldMap = {},
323
+ Shape = Type extends DrizzleRef<any, keyof Types['DrizzleRelationSchema'], infer S>
324
+ ? S
325
+ : BuildQueryResult<
326
+ Types['DrizzleRelationSchema'],
327
+ Types['DrizzleRelationSchema'][Type & keyof Types['DrizzleRelationSchema']],
328
+ true
329
+ >,
330
+ ConnectionInterfaces extends InterfaceParam<Types>[] = [],
331
+ EdgeInterfaces extends InterfaceParam<Types>[] = [],
332
+ >(
333
+ options: DrizzleConnectionFieldOptions<
334
+ Types,
335
+ ParentShape,
336
+ Type,
337
+ Types['DrizzleRelationSchema'][Type extends DrizzleRef<any, infer K>
338
+ ? K
339
+ : Type & keyof Types['DrizzleRelationSchema']],
340
+ ObjectRef<Types, Shape>,
341
+ Nullable,
342
+ Args,
343
+ ResolveReturnShape,
344
+ Kind
345
+ >,
346
+ ...args: NormalizeArgs<
347
+ [
348
+ connectionOptions:
349
+ | ConnectionObjectOptions<
350
+ Types,
351
+ ObjectRef<Types, Shape>,
352
+ false,
353
+ false,
354
+ DrizzleConnectionShape<Types, Shape, ParentShape, Args>,
355
+ ConnectionInterfaces
356
+ >
357
+ | ObjectRef<
358
+ Types,
359
+ ShapeFromConnection<ConnectionShapeHelper<Types, Shape, false>>
360
+ >,
361
+ edgeOptions:
362
+ | ConnectionEdgeObjectOptions<
363
+ Types,
364
+ ObjectRef<Types, Shape>,
365
+ false,
366
+ DrizzleConnectionShape<Types, Shape, ParentShape, Args>,
367
+ EdgeInterfaces
368
+ >
369
+ | ObjectRef<
370
+ Types,
371
+ {
372
+ cursor: string;
373
+ node?: Shape | null | undefined;
374
+ }
375
+ >,
376
+ ],
377
+ 0
378
+ >
379
+ ) => FieldRef<Types, ShapeFromConnection<ConnectionShapeHelper<Types, Shape, Nullable>>>
380
+ : '@pothos/plugin-relay is required to use this method';
381
+
382
+ drizzleFieldWithInput: 'withInput' extends PluginName
383
+ ? <
384
+ Fields extends InputFieldMap,
385
+ Args extends InputFieldMap,
386
+ Param extends
387
+ | keyof Types['DrizzleRelationSchema']
388
+ | [keyof Types['DrizzleRelationSchema']]
389
+ | DrizzleRef<any>
390
+ | [DrizzleRef<any>],
391
+ Nullable extends FieldNullability<Type>,
392
+ ResolveShape,
393
+ ResolveReturnShape,
394
+ ArgRequired extends boolean,
395
+ InputName extends string = 'input',
396
+ Table extends
397
+ keyof Types['DrizzleRelationSchema'] = Param extends keyof Types['DrizzleRelationSchema']
398
+ ? Param
399
+ : Param extends [keyof Types['DrizzleRelationSchema']]
400
+ ? Param[0]
401
+ : Param extends DrizzleRef<any, infer T>
402
+ ? T & keyof Types['DrizzleRelationSchema']
403
+ : Param extends [DrizzleRef<any, infer T>]
404
+ ? T & keyof Types['DrizzleRelationSchema']
405
+ : never,
406
+ Type extends TypeParam<Types> = ObjectRef<
407
+ Types,
408
+ BuildQueryResult<
409
+ Types['DrizzleRelationSchema'],
410
+ Types['DrizzleRelationSchema'][Table],
411
+ true
412
+ >
413
+ >,
414
+ >(
415
+ options: DrizzleFieldWithInputOptions<
416
+ Types,
417
+ ParentShape,
418
+ Table,
419
+ Type,
420
+ Nullable,
421
+ Args,
422
+ Kind,
423
+ ResolveShape,
424
+ ResolveReturnShape,
425
+ Param,
426
+ InputName,
427
+ Fields,
428
+ boolean extends ArgRequired
429
+ ? (Types & { WithInputArgRequired: boolean })['WithInputArgRequired']
430
+ : ArgRequired
431
+ >,
432
+ ) => FieldRef<Types, ShapeFromTypeParam<Types, Type, Nullable>>
433
+ : '@pothos/plugin-with-input is required to use this method';
434
+ }
435
+
436
+ export interface ConnectionFieldOptions<
437
+ Types extends SchemaTypes,
438
+ ParentShape,
439
+ Type extends OutputType<Types>,
440
+ Nullable extends boolean,
441
+ EdgeNullability extends FieldNullability<[unknown]>,
442
+ NodeNullability extends boolean,
443
+ Args extends InputFieldMap,
444
+ ResolveReturnShape,
445
+ > {}
446
+
447
+ export interface ConnectionObjectOptions<
448
+ Types extends SchemaTypes,
449
+ Type extends OutputType<Types>,
450
+ EdgeNullability extends FieldNullability<[unknown]>,
451
+ NodeNullability extends boolean,
452
+ Resolved,
453
+ Interfaces extends InterfaceParam<Types>[] = [],
454
+ > {}
455
+
456
+ export interface ConnectionEdgeObjectOptions<
457
+ Types extends SchemaTypes,
458
+ Type extends OutputType<Types>,
459
+ NodeNullability extends boolean,
460
+ Resolved,
461
+ Interfaces extends InterfaceParam<Types>[] = [],
462
+ > {}
463
+
464
+ export interface DefaultConnectionArguments {
465
+ first?: number | null | undefined;
466
+ last?: number | null | undefined;
467
+ before?: string | null | undefined;
468
+ after?: string | null | undefined;
469
+ }
470
+
471
+ export interface ConnectionShapeHelper<Types extends SchemaTypes, T, Nullable> {}
472
+
473
+ export interface FieldWithInputBaseOptions<
474
+ Types extends SchemaTypes,
475
+ Args extends InputFieldMap,
476
+ Fields extends InputFieldMap,
477
+ InputName extends string,
478
+ ArgRequired extends boolean,
479
+ > {}
480
+ }
481
+ }