drizzle-graphql-plus 0.8.14 → 0.8.16
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/index.cjs +754 -8
- package/index.cjs.map +1 -1
- package/index.d.cts +136 -5
- package/index.d.ts +136 -5
- package/index.js +773 -6
- package/index.js.map +1 -1
- package/package.json +9 -4
package/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Table, Column, TablesRelationalConfig, TableRelationalConfig, Relations, Relation, One, Many } from 'drizzle-orm';
|
|
1
|
+
import { Table, Column, TablesRelationalConfig, TableRelationalConfig, Relations, Relation, One, Many, InferSelectModel, getTableColumns } from 'drizzle-orm';
|
|
2
2
|
import { MySqlDatabase } from 'drizzle-orm/mysql-core';
|
|
3
3
|
import { RelationalQueryBuilder as RelationalQueryBuilder$1 } from 'drizzle-orm/mysql-core/query-builders/query';
|
|
4
4
|
import { PgDatabase } from 'drizzle-orm/pg-core';
|
|
@@ -82,7 +82,7 @@ type ExtractTableByName<TTableSchema extends Record<string, Table>, TName extend
|
|
|
82
82
|
type MutationReturnlessResult = {
|
|
83
83
|
isSuccess: boolean;
|
|
84
84
|
};
|
|
85
|
-
type QueryArgs<TTable extends Table, isSingle extends boolean> = Partial<(isSingle extends true ? {
|
|
85
|
+
type QueryArgs$1<TTable extends Table, isSingle extends boolean> = Partial<(isSingle extends true ? {
|
|
86
86
|
offset: number;
|
|
87
87
|
} : {
|
|
88
88
|
offset: number;
|
|
@@ -103,10 +103,10 @@ type UpdateArgs<TTable extends Table> = Partial<{
|
|
|
103
103
|
type DeleteArgs<TTable extends Table> = {
|
|
104
104
|
where?: Filters<TTable>;
|
|
105
105
|
};
|
|
106
|
-
type SelectResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<keyof TRelations extends infer RelKey ? RelKey extends string ? Array<GetRemappedTableDataType<TTable> & {
|
|
106
|
+
type SelectResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs$1<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<keyof TRelations extends infer RelKey ? RelKey extends string ? Array<GetRemappedTableDataType<TTable> & {
|
|
107
107
|
[K in RelKey]: TRelations[K] extends One<string> ? GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never> | null : TRelations[K] extends Many<string> ? Array<GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never>> : never;
|
|
108
108
|
}> : Array<GetRemappedTableDataType<TTable>> : Array<GetRemappedTableDataType<TTable>>>;
|
|
109
|
-
type SelectSingleResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs<TTable, true>>, context: any, info: GraphQLResolveInfo) => Promise<(keyof TRelations extends infer RelKey ? RelKey extends string ? GetRemappedTableDataType<TTable> & {
|
|
109
|
+
type SelectSingleResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs$1<TTable, true>>, context: any, info: GraphQLResolveInfo) => Promise<(keyof TRelations extends infer RelKey ? RelKey extends string ? GetRemappedTableDataType<TTable> & {
|
|
110
110
|
[K in RelKey]: TRelations[K] extends One<string> ? GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never> | null : TRelations[K] extends Many<string> ? Array<GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never>> : never;
|
|
111
111
|
} : GetRemappedTableDataType<TTable> : GetRemappedTableDataType<TTable>) | null>;
|
|
112
112
|
type InsertResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: Partial<InsertArgs<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? Array<GetRemappedTableDataType<TTable>> : MutationReturnlessResult>;
|
|
@@ -248,4 +248,135 @@ type BuildSchemaConfig = {
|
|
|
248
248
|
|
|
249
249
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
type Capitalize$1<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
|
|
252
|
+
type ColumnFilter<T = any> = {
|
|
253
|
+
eq?: T;
|
|
254
|
+
ne?: T;
|
|
255
|
+
gt?: T;
|
|
256
|
+
gte?: T;
|
|
257
|
+
lt?: T;
|
|
258
|
+
lte?: T;
|
|
259
|
+
like?: string;
|
|
260
|
+
notLike?: string;
|
|
261
|
+
ilike?: string;
|
|
262
|
+
notIlike?: string;
|
|
263
|
+
inArray?: T[];
|
|
264
|
+
notInArray?: T[];
|
|
265
|
+
isNull?: boolean;
|
|
266
|
+
isNotNull?: boolean;
|
|
267
|
+
OR?: ColumnFilter<T>[];
|
|
268
|
+
};
|
|
269
|
+
type WhereInput<TTable> = TTable extends {
|
|
270
|
+
$inferSelect: infer S;
|
|
271
|
+
} ? {
|
|
272
|
+
[K in keyof S]?: ColumnFilter<S[K]>;
|
|
273
|
+
} & {
|
|
274
|
+
OR?: WhereInput<TTable>[];
|
|
275
|
+
} : never;
|
|
276
|
+
type OrderByInput<TTable> = TTable extends {
|
|
277
|
+
$inferSelect: infer S;
|
|
278
|
+
} ? {
|
|
279
|
+
[K in keyof S]?: {
|
|
280
|
+
direction: "asc" | "desc";
|
|
281
|
+
priority: number;
|
|
282
|
+
};
|
|
283
|
+
} : never;
|
|
284
|
+
type QueryArgs<TTable> = {
|
|
285
|
+
where?: WhereInput<TTable>;
|
|
286
|
+
orderBy?: OrderByInput<TTable>;
|
|
287
|
+
limit?: number;
|
|
288
|
+
offset?: number;
|
|
289
|
+
};
|
|
290
|
+
type InsertInput<TTable> = TTable extends {
|
|
291
|
+
$inferInsert: infer I;
|
|
292
|
+
} ? I : never;
|
|
293
|
+
type UpdateInput<TTable> = TTable extends {
|
|
294
|
+
$inferInsert: infer I;
|
|
295
|
+
} ? Partial<I> : never;
|
|
296
|
+
type BuildSchemaSDLResult<TSchema extends Record<string, any> = Record<string, any>> = {
|
|
297
|
+
typeDefs: string;
|
|
298
|
+
resolvers: {
|
|
299
|
+
Query: {
|
|
300
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
301
|
+
$inferSelect: any;
|
|
302
|
+
} ? K : never]: (parent: any, args: QueryArgs<TSchema[K]>, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
303
|
+
};
|
|
304
|
+
Mutation: {
|
|
305
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
306
|
+
$inferSelect: any;
|
|
307
|
+
} ? `insert${Capitalize$1<K & string>}` : never]: (parent: any, args: {
|
|
308
|
+
data: InsertInput<TSchema[K]> | InsertInput<TSchema[K]>[];
|
|
309
|
+
}, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
310
|
+
} & {
|
|
311
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
312
|
+
$inferSelect: any;
|
|
313
|
+
} ? `update${Capitalize$1<K & string>}` : never]: (parent: any, args: {
|
|
314
|
+
data: UpdateInput<TSchema[K]>;
|
|
315
|
+
where: WhereInput<TSchema[K]>;
|
|
316
|
+
}, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
317
|
+
} & {
|
|
318
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
319
|
+
$inferSelect: any;
|
|
320
|
+
} ? `delete${Capitalize$1<K & string>}` : never]: (parent: any, args: {
|
|
321
|
+
where: WhereInput<TSchema[K]>;
|
|
322
|
+
}, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
323
|
+
};
|
|
324
|
+
[key: string]: any;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
declare const buildSchemaSDL: <TDbClient extends AnyDrizzleDB<any>, TSchema extends Record<string, any> = TDbClient extends {
|
|
328
|
+
_: {
|
|
329
|
+
fullSchema: infer S;
|
|
330
|
+
};
|
|
331
|
+
} ? S : Record<string, any>>(db: TDbClient, config?: BuildSchemaConfig) => BuildSchemaSDLResult<TSchema>;
|
|
332
|
+
|
|
333
|
+
interface GraphQLFieldConfig {
|
|
334
|
+
type: string;
|
|
335
|
+
description?: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Helper function to customize GraphQL schema generation for specific columns.
|
|
339
|
+
* Allows you to override the default type mapping and add field descriptions.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* import { setCustomGraphQL } from 'drizzle-graphql-plus';
|
|
344
|
+
*
|
|
345
|
+
* export const user = sqliteTable("user", {
|
|
346
|
+
* id: text("id").primaryKey(),
|
|
347
|
+
* email: text("email").notNull(),
|
|
348
|
+
* createdAt: integer("created_at"),
|
|
349
|
+
* });
|
|
350
|
+
*
|
|
351
|
+
* // Customize GraphQL fields - TypeScript will autocomplete column names!
|
|
352
|
+
* setCustomGraphQL(user, {
|
|
353
|
+
* id: { type: "ULID", description: "Unique identifier using ULID format" },
|
|
354
|
+
* email: { type: "String", description: "User's email address" },
|
|
355
|
+
* createdAt: { type: "DateTime", description: "Account creation timestamp" },
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* You can also use shorthand for type-only config:
|
|
360
|
+
* ```typescript
|
|
361
|
+
* setCustomGraphQL(user, {
|
|
362
|
+
* id: "ULID",
|
|
363
|
+
* createdAt: "DateTime",
|
|
364
|
+
* });
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* Then in your server, define the custom types:
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const customTypes = `
|
|
370
|
+
* scalar ULID
|
|
371
|
+
* scalar DateTime
|
|
372
|
+
* `;
|
|
373
|
+
* const typeDefs = customTypes + "\n" + generatedTypeDefs;
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
declare function setCustomGraphQL<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnConfig: Partial<Record<keyof TColumns, string | GraphQLFieldConfig>>): void;
|
|
377
|
+
/**
|
|
378
|
+
* @deprecated Use setCustomGraphQL instead
|
|
379
|
+
*/
|
|
380
|
+
declare function setCustomGraphQLTypes<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnTypes: Partial<Record<keyof TColumns, string>>): void;
|
|
381
|
+
|
|
382
|
+
export { type AnyDrizzleDB, type AnyQueryBuiler, type BuildSchemaConfig, type BuildSchemaSDLResult, type DeleteArgs, type DeleteResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedInterfaces, type GeneratedOutputs, type GraphQLFieldConfig, type InsertArgs, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type QueryArgs$1 as QueryArgs, type SelectResolver, type SelectSingleResolver, type UpdateArgs, type UpdateResolver, buildSchema, buildSchemaSDL, setCustomGraphQL, setCustomGraphQLTypes };
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Table, Column, TablesRelationalConfig, TableRelationalConfig, Relations, Relation, One, Many } from 'drizzle-orm';
|
|
1
|
+
import { Table, Column, TablesRelationalConfig, TableRelationalConfig, Relations, Relation, One, Many, InferSelectModel, getTableColumns } from 'drizzle-orm';
|
|
2
2
|
import { MySqlDatabase } from 'drizzle-orm/mysql-core';
|
|
3
3
|
import { RelationalQueryBuilder as RelationalQueryBuilder$1 } from 'drizzle-orm/mysql-core/query-builders/query';
|
|
4
4
|
import { PgDatabase } from 'drizzle-orm/pg-core';
|
|
@@ -82,7 +82,7 @@ type ExtractTableByName<TTableSchema extends Record<string, Table>, TName extend
|
|
|
82
82
|
type MutationReturnlessResult = {
|
|
83
83
|
isSuccess: boolean;
|
|
84
84
|
};
|
|
85
|
-
type QueryArgs<TTable extends Table, isSingle extends boolean> = Partial<(isSingle extends true ? {
|
|
85
|
+
type QueryArgs$1<TTable extends Table, isSingle extends boolean> = Partial<(isSingle extends true ? {
|
|
86
86
|
offset: number;
|
|
87
87
|
} : {
|
|
88
88
|
offset: number;
|
|
@@ -103,10 +103,10 @@ type UpdateArgs<TTable extends Table> = Partial<{
|
|
|
103
103
|
type DeleteArgs<TTable extends Table> = {
|
|
104
104
|
where?: Filters<TTable>;
|
|
105
105
|
};
|
|
106
|
-
type SelectResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<keyof TRelations extends infer RelKey ? RelKey extends string ? Array<GetRemappedTableDataType<TTable> & {
|
|
106
|
+
type SelectResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs$1<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<keyof TRelations extends infer RelKey ? RelKey extends string ? Array<GetRemappedTableDataType<TTable> & {
|
|
107
107
|
[K in RelKey]: TRelations[K] extends One<string> ? GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never> | null : TRelations[K] extends Many<string> ? Array<GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never>> : never;
|
|
108
108
|
}> : Array<GetRemappedTableDataType<TTable>> : Array<GetRemappedTableDataType<TTable>>>;
|
|
109
|
-
type SelectSingleResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs<TTable, true>>, context: any, info: GraphQLResolveInfo) => Promise<(keyof TRelations extends infer RelKey ? RelKey extends string ? GetRemappedTableDataType<TTable> & {
|
|
109
|
+
type SelectSingleResolver<TTable extends Table, TTables extends Record<string, Table>, TRelations extends Record<string, Relation>> = (source: any, args: Partial<QueryArgs$1<TTable, true>>, context: any, info: GraphQLResolveInfo) => Promise<(keyof TRelations extends infer RelKey ? RelKey extends string ? GetRemappedTableDataType<TTable> & {
|
|
110
110
|
[K in RelKey]: TRelations[K] extends One<string> ? GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never> | null : TRelations[K] extends Many<string> ? Array<GetRemappedTableDataType<ExtractTableByName<TTables, TRelations[K]["referencedTableName"]> extends infer T ? T[keyof T] : never>> : never;
|
|
111
111
|
} : GetRemappedTableDataType<TTable> : GetRemappedTableDataType<TTable>) | null>;
|
|
112
112
|
type InsertResolver<TTable extends Table, IsReturnless extends boolean> = (source: any, args: Partial<InsertArgs<TTable, false>>, context: any, info: GraphQLResolveInfo) => Promise<IsReturnless extends false ? Array<GetRemappedTableDataType<TTable>> : MutationReturnlessResult>;
|
|
@@ -248,4 +248,135 @@ type BuildSchemaConfig = {
|
|
|
248
248
|
|
|
249
249
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
type Capitalize$1<S extends string> = S extends `${infer F}${infer R}` ? `${Uppercase<F>}${R}` : S;
|
|
252
|
+
type ColumnFilter<T = any> = {
|
|
253
|
+
eq?: T;
|
|
254
|
+
ne?: T;
|
|
255
|
+
gt?: T;
|
|
256
|
+
gte?: T;
|
|
257
|
+
lt?: T;
|
|
258
|
+
lte?: T;
|
|
259
|
+
like?: string;
|
|
260
|
+
notLike?: string;
|
|
261
|
+
ilike?: string;
|
|
262
|
+
notIlike?: string;
|
|
263
|
+
inArray?: T[];
|
|
264
|
+
notInArray?: T[];
|
|
265
|
+
isNull?: boolean;
|
|
266
|
+
isNotNull?: boolean;
|
|
267
|
+
OR?: ColumnFilter<T>[];
|
|
268
|
+
};
|
|
269
|
+
type WhereInput<TTable> = TTable extends {
|
|
270
|
+
$inferSelect: infer S;
|
|
271
|
+
} ? {
|
|
272
|
+
[K in keyof S]?: ColumnFilter<S[K]>;
|
|
273
|
+
} & {
|
|
274
|
+
OR?: WhereInput<TTable>[];
|
|
275
|
+
} : never;
|
|
276
|
+
type OrderByInput<TTable> = TTable extends {
|
|
277
|
+
$inferSelect: infer S;
|
|
278
|
+
} ? {
|
|
279
|
+
[K in keyof S]?: {
|
|
280
|
+
direction: "asc" | "desc";
|
|
281
|
+
priority: number;
|
|
282
|
+
};
|
|
283
|
+
} : never;
|
|
284
|
+
type QueryArgs<TTable> = {
|
|
285
|
+
where?: WhereInput<TTable>;
|
|
286
|
+
orderBy?: OrderByInput<TTable>;
|
|
287
|
+
limit?: number;
|
|
288
|
+
offset?: number;
|
|
289
|
+
};
|
|
290
|
+
type InsertInput<TTable> = TTable extends {
|
|
291
|
+
$inferInsert: infer I;
|
|
292
|
+
} ? I : never;
|
|
293
|
+
type UpdateInput<TTable> = TTable extends {
|
|
294
|
+
$inferInsert: infer I;
|
|
295
|
+
} ? Partial<I> : never;
|
|
296
|
+
type BuildSchemaSDLResult<TSchema extends Record<string, any> = Record<string, any>> = {
|
|
297
|
+
typeDefs: string;
|
|
298
|
+
resolvers: {
|
|
299
|
+
Query: {
|
|
300
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
301
|
+
$inferSelect: any;
|
|
302
|
+
} ? K : never]: (parent: any, args: QueryArgs<TSchema[K]>, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
303
|
+
};
|
|
304
|
+
Mutation: {
|
|
305
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
306
|
+
$inferSelect: any;
|
|
307
|
+
} ? `insert${Capitalize$1<K & string>}` : never]: (parent: any, args: {
|
|
308
|
+
data: InsertInput<TSchema[K]> | InsertInput<TSchema[K]>[];
|
|
309
|
+
}, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
310
|
+
} & {
|
|
311
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
312
|
+
$inferSelect: any;
|
|
313
|
+
} ? `update${Capitalize$1<K & string>}` : never]: (parent: any, args: {
|
|
314
|
+
data: UpdateInput<TSchema[K]>;
|
|
315
|
+
where: WhereInput<TSchema[K]>;
|
|
316
|
+
}, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
317
|
+
} & {
|
|
318
|
+
[K in keyof TSchema as TSchema[K] extends {
|
|
319
|
+
$inferSelect: any;
|
|
320
|
+
} ? `delete${Capitalize$1<K & string>}` : never]: (parent: any, args: {
|
|
321
|
+
where: WhereInput<TSchema[K]>;
|
|
322
|
+
}, context: any, info: any) => Promise<InferSelectModel<TSchema[K]>[]>;
|
|
323
|
+
};
|
|
324
|
+
[key: string]: any;
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
declare const buildSchemaSDL: <TDbClient extends AnyDrizzleDB<any>, TSchema extends Record<string, any> = TDbClient extends {
|
|
328
|
+
_: {
|
|
329
|
+
fullSchema: infer S;
|
|
330
|
+
};
|
|
331
|
+
} ? S : Record<string, any>>(db: TDbClient, config?: BuildSchemaConfig) => BuildSchemaSDLResult<TSchema>;
|
|
332
|
+
|
|
333
|
+
interface GraphQLFieldConfig {
|
|
334
|
+
type: string;
|
|
335
|
+
description?: string;
|
|
336
|
+
}
|
|
337
|
+
/**
|
|
338
|
+
* Helper function to customize GraphQL schema generation for specific columns.
|
|
339
|
+
* Allows you to override the default type mapping and add field descriptions.
|
|
340
|
+
*
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* import { setCustomGraphQL } from 'drizzle-graphql-plus';
|
|
344
|
+
*
|
|
345
|
+
* export const user = sqliteTable("user", {
|
|
346
|
+
* id: text("id").primaryKey(),
|
|
347
|
+
* email: text("email").notNull(),
|
|
348
|
+
* createdAt: integer("created_at"),
|
|
349
|
+
* });
|
|
350
|
+
*
|
|
351
|
+
* // Customize GraphQL fields - TypeScript will autocomplete column names!
|
|
352
|
+
* setCustomGraphQL(user, {
|
|
353
|
+
* id: { type: "ULID", description: "Unique identifier using ULID format" },
|
|
354
|
+
* email: { type: "String", description: "User's email address" },
|
|
355
|
+
* createdAt: { type: "DateTime", description: "Account creation timestamp" },
|
|
356
|
+
* });
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* You can also use shorthand for type-only config:
|
|
360
|
+
* ```typescript
|
|
361
|
+
* setCustomGraphQL(user, {
|
|
362
|
+
* id: "ULID",
|
|
363
|
+
* createdAt: "DateTime",
|
|
364
|
+
* });
|
|
365
|
+
* ```
|
|
366
|
+
*
|
|
367
|
+
* Then in your server, define the custom types:
|
|
368
|
+
* ```typescript
|
|
369
|
+
* const customTypes = `
|
|
370
|
+
* scalar ULID
|
|
371
|
+
* scalar DateTime
|
|
372
|
+
* `;
|
|
373
|
+
* const typeDefs = customTypes + "\n" + generatedTypeDefs;
|
|
374
|
+
* ```
|
|
375
|
+
*/
|
|
376
|
+
declare function setCustomGraphQL<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnConfig: Partial<Record<keyof TColumns, string | GraphQLFieldConfig>>): void;
|
|
377
|
+
/**
|
|
378
|
+
* @deprecated Use setCustomGraphQL instead
|
|
379
|
+
*/
|
|
380
|
+
declare function setCustomGraphQLTypes<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnTypes: Partial<Record<keyof TColumns, string>>): void;
|
|
381
|
+
|
|
382
|
+
export { type AnyDrizzleDB, type AnyQueryBuiler, type BuildSchemaConfig, type BuildSchemaSDLResult, type DeleteArgs, type DeleteResolver, type ExtractRelations, type ExtractTableByName, type ExtractTableRelations, type ExtractTables, type GeneratedData, type GeneratedEntities, type GeneratedInputs, type GeneratedInterfaces, type GeneratedOutputs, type GraphQLFieldConfig, type InsertArgs, type InsertArrResolver, type InsertResolver, type MutationReturnlessResult, type MutationsCore, type QueriesCore, type QueryArgs$1 as QueryArgs, type SelectResolver, type SelectSingleResolver, type UpdateArgs, type UpdateResolver, buildSchema, buildSchemaSDL, setCustomGraphQL, setCustomGraphQLTypes };
|