Skip to content

Commit

Permalink
Add changeset and mirror change in drizzle plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
hayes committed Nov 1, 2024
1 parent 16661cf commit 52a70e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/nice-fishes-switch.md
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions packages/plugin-drizzle/src/model-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export class ModelLoader {
table: TableRelationalConfig;
columns: Column[];
selectSQL;
client: DrizzleClient;

constructor(
context: object,
Expand All @@ -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<Types extends SchemaTypes>(
Expand Down Expand Up @@ -166,11 +163,12 @@ export class ModelLoader {
this.staged.add(entry);

const nextTick = createResolvablePromise<void>();
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<Record<string, unknown>[]> }
>
Expand Down

0 comments on commit 52a70e9

Please sign in to comment.