From 52a70e9504ab250ac116ce50c8e6ccd6e8be609f Mon Sep 17 00:00:00 2001 From: Michael Hayes Date: Fri, 1 Nov 2024 14:20:07 -0700 Subject: [PATCH] Add changeset and mirror change in drizzle plugin --- .changeset/nice-fishes-switch.md | 6 ++++++ packages/plugin-drizzle/src/model-loader.ts | 6 ++---- 2 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .changeset/nice-fishes-switch.md diff --git a/.changeset/nice-fishes-switch.md b/.changeset/nice-fishes-switch.md new file mode 100644 index 000000000..e99ab6b51 --- /dev/null +++ b/.changeset/nice-fishes-switch.md @@ -0,0 +1,6 @@ +--- +"@pothos/plugin-drizzle": patch +"@pothos/plugin-prisma": patch +--- + +Load client when db request is initialized rather than caching on model loader diff --git a/packages/plugin-drizzle/src/model-loader.ts b/packages/plugin-drizzle/src/model-loader.ts index 10d16bb4a..b9bf545ee 100644 --- a/packages/plugin-drizzle/src/model-loader.ts +++ b/packages/plugin-drizzle/src/model-loader.ts @@ -36,7 +36,6 @@ export class ModelLoader { table: TableRelationalConfig; columns: Column[]; selectSQL; - client: DrizzleClient; constructor( context: object, @@ -54,8 +53,6 @@ export class ModelLoader { this.columns.length > 1 ? sql`(${sql.join(this.columns, sql`, `)})` : this.columns[0].getSQL(); - - this.client = getClient(builder, context); } static forModel( @@ -166,11 +163,12 @@ export class ModelLoader { this.staged.add(entry); const nextTick = createResolvablePromise(); + const client = getClient(this.builder, this.context); nextTick.promise .then(() => { const api = ( - this.client.query as Record< + client.query as Record< string, { findMany: (...args: unknown[]) => Promise[]> } >