drizzle-graphql-plus 0.8.13 → 0.8.15
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 +810 -32
- package/index.cjs.map +1 -1
- package/index.d.cts +57 -2
- package/index.d.ts +57 -2
- package/index.js +829 -30
- package/index.js.map +1 -1
- package/package.json +9 -2
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, 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';
|
|
@@ -248,4 +248,59 @@ type BuildSchemaConfig = {
|
|
|
248
248
|
|
|
249
249
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
type BuildSchemaSDLResult = {
|
|
252
|
+
typeDefs: string;
|
|
253
|
+
resolvers: Record<string, any>;
|
|
254
|
+
};
|
|
255
|
+
declare const buildSchemaSDL: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => BuildSchemaSDLResult;
|
|
256
|
+
|
|
257
|
+
interface GraphQLFieldConfig {
|
|
258
|
+
type: string;
|
|
259
|
+
description?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Helper function to customize GraphQL schema generation for specific columns.
|
|
263
|
+
* Allows you to override the default type mapping and add field descriptions.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* import { setCustomGraphQL } from 'drizzle-graphql-plus';
|
|
268
|
+
*
|
|
269
|
+
* export const user = sqliteTable("user", {
|
|
270
|
+
* id: text("id").primaryKey(),
|
|
271
|
+
* email: text("email").notNull(),
|
|
272
|
+
* createdAt: integer("created_at"),
|
|
273
|
+
* });
|
|
274
|
+
*
|
|
275
|
+
* // Customize GraphQL fields - TypeScript will autocomplete column names!
|
|
276
|
+
* setCustomGraphQL(user, {
|
|
277
|
+
* id: { type: "ULID", description: "Unique identifier using ULID format" },
|
|
278
|
+
* email: { type: "String", description: "User's email address" },
|
|
279
|
+
* createdAt: { type: "DateTime", description: "Account creation timestamp" },
|
|
280
|
+
* });
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* You can also use shorthand for type-only config:
|
|
284
|
+
* ```typescript
|
|
285
|
+
* setCustomGraphQL(user, {
|
|
286
|
+
* id: "ULID",
|
|
287
|
+
* createdAt: "DateTime",
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* Then in your server, define the custom types:
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const customTypes = `
|
|
294
|
+
* scalar ULID
|
|
295
|
+
* scalar DateTime
|
|
296
|
+
* `;
|
|
297
|
+
* const typeDefs = customTypes + "\n" + generatedTypeDefs;
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
declare function setCustomGraphQL<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnConfig: Partial<Record<keyof TColumns, string | GraphQLFieldConfig>>): void;
|
|
301
|
+
/**
|
|
302
|
+
* @deprecated Use setCustomGraphQL instead
|
|
303
|
+
*/
|
|
304
|
+
declare function setCustomGraphQLTypes<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnTypes: Partial<Record<keyof TColumns, string>>): void;
|
|
305
|
+
|
|
306
|
+
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, 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, 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';
|
|
@@ -248,4 +248,59 @@ type BuildSchemaConfig = {
|
|
|
248
248
|
|
|
249
249
|
declare const buildSchema: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => GeneratedData<TDbClient>;
|
|
250
250
|
|
|
251
|
-
|
|
251
|
+
type BuildSchemaSDLResult = {
|
|
252
|
+
typeDefs: string;
|
|
253
|
+
resolvers: Record<string, any>;
|
|
254
|
+
};
|
|
255
|
+
declare const buildSchemaSDL: <TDbClient extends AnyDrizzleDB<any>>(db: TDbClient, config?: BuildSchemaConfig) => BuildSchemaSDLResult;
|
|
256
|
+
|
|
257
|
+
interface GraphQLFieldConfig {
|
|
258
|
+
type: string;
|
|
259
|
+
description?: string;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Helper function to customize GraphQL schema generation for specific columns.
|
|
263
|
+
* Allows you to override the default type mapping and add field descriptions.
|
|
264
|
+
*
|
|
265
|
+
* @example
|
|
266
|
+
* ```typescript
|
|
267
|
+
* import { setCustomGraphQL } from 'drizzle-graphql-plus';
|
|
268
|
+
*
|
|
269
|
+
* export const user = sqliteTable("user", {
|
|
270
|
+
* id: text("id").primaryKey(),
|
|
271
|
+
* email: text("email").notNull(),
|
|
272
|
+
* createdAt: integer("created_at"),
|
|
273
|
+
* });
|
|
274
|
+
*
|
|
275
|
+
* // Customize GraphQL fields - TypeScript will autocomplete column names!
|
|
276
|
+
* setCustomGraphQL(user, {
|
|
277
|
+
* id: { type: "ULID", description: "Unique identifier using ULID format" },
|
|
278
|
+
* email: { type: "String", description: "User's email address" },
|
|
279
|
+
* createdAt: { type: "DateTime", description: "Account creation timestamp" },
|
|
280
|
+
* });
|
|
281
|
+
* ```
|
|
282
|
+
*
|
|
283
|
+
* You can also use shorthand for type-only config:
|
|
284
|
+
* ```typescript
|
|
285
|
+
* setCustomGraphQL(user, {
|
|
286
|
+
* id: "ULID",
|
|
287
|
+
* createdAt: "DateTime",
|
|
288
|
+
* });
|
|
289
|
+
* ```
|
|
290
|
+
*
|
|
291
|
+
* Then in your server, define the custom types:
|
|
292
|
+
* ```typescript
|
|
293
|
+
* const customTypes = `
|
|
294
|
+
* scalar ULID
|
|
295
|
+
* scalar DateTime
|
|
296
|
+
* `;
|
|
297
|
+
* const typeDefs = customTypes + "\n" + generatedTypeDefs;
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
declare function setCustomGraphQL<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnConfig: Partial<Record<keyof TColumns, string | GraphQLFieldConfig>>): void;
|
|
301
|
+
/**
|
|
302
|
+
* @deprecated Use setCustomGraphQL instead
|
|
303
|
+
*/
|
|
304
|
+
declare function setCustomGraphQLTypes<T extends Table, TColumns = ReturnType<typeof getTableColumns<T>>>(table: T, columnTypes: Partial<Record<keyof TColumns, string>>): void;
|
|
305
|
+
|
|
306
|
+
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, type SelectResolver, type SelectSingleResolver, type UpdateArgs, type UpdateResolver, buildSchema, buildSchemaSDL, setCustomGraphQL, setCustomGraphQLTypes };
|