Skip to content

Commit 9a664a0

Browse files
committed
Fixed on custom-named mutations in PostgreSQL & SQLite, added tests for custom queries & mutations, fixed misplaced import, bumped version
1 parent 33e809c commit 9a664a0

File tree

7 files changed

+4343
-11
lines changed

7 files changed

+4343
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "drizzle-graphql",
33
"type": "module",
44
"author": "Drizzle Team",
5-
"version": "0.3.4",
5+
"version": "0.3.5",
66
"description": "Automatically generate GraphQL schema or customizable schema config fields from Drizzle ORM schema",
77
"scripts": {
88
"build": "pnpm tsx scripts/build.ts",

src/util/builders/pg.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const generateInsertArray = (
185185
const input = remapFromGraphQLArrayInput(args.values, table);
186186
if (!input.length) throw new GraphQLError('No values were provided!');
187187

188-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, PgColumn>;
188+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, PgColumn>;
189189

190190
const result = await db.insert(table).values(input).returning(columns).onConflictDoNothing();
191191

@@ -222,7 +222,7 @@ const generateInsertSingle = (
222222
try {
223223
const input = remapFromGraphQLSingleInput(args.values, table);
224224

225-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, PgColumn>;
225+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, PgColumn>;
226226

227227
const result = await db.insert(table).values(input).returning(columns).onConflictDoNothing();
228228

@@ -265,7 +265,7 @@ const generateUpdate = (
265265
try {
266266
const { where, set } = args;
267267

268-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, PgColumn>;
268+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, PgColumn>;
269269
const input = remapFromGraphQLSingleInput(set, table);
270270
if (!Object.keys(input).length) throw new GraphQLError('Unable to update with no values specified!');
271271

@@ -312,7 +312,7 @@ const generateDelete = (
312312
try {
313313
const { where } = args;
314314

315-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, PgColumn>;
315+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, PgColumn>;
316316

317317
let query = db.delete(table);
318318
if (where) {

src/util/builders/sqlite.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ const generateInsertArray = (
185185
const input = remapFromGraphQLArrayInput(args.values, table);
186186
if (!input.length) throw new GraphQLError('No values were provided!');
187187

188-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, SQLiteColumn>;
188+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, SQLiteColumn>;
189189

190190
const result = await db
191191
.insert(table)
@@ -226,7 +226,7 @@ const generateInsertSingle = (
226226
try {
227227
const input = remapFromGraphQLSingleInput(args.values, table);
228228

229-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, SQLiteColumn>;
229+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, SQLiteColumn>;
230230

231231
const result = await db.insert(table).values(input).returning(columns).onConflictDoNothing();
232232

@@ -269,7 +269,7 @@ const generateUpdate = (
269269
try {
270270
const { where, set } = args;
271271

272-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, SQLiteColumn>;
272+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, SQLiteColumn>;
273273
const input = remapFromGraphQLSingleInput(set, table);
274274
if (!Object.keys(input).length) throw new GraphQLError('Unable to update with no values specified!');
275275

@@ -316,7 +316,7 @@ const generateDelete = (
316316
try {
317317
const { where } = args;
318318

319-
const columns = extractSelectedColumnsSQLFormat(info, queryName, table) as Record<string, SQLiteColumn>;
319+
const columns = extractSelectedColumnsSQLFormat(info, info.fieldName, table) as Record<string, SQLiteColumn>;
320320

321321
let query = db.delete(table);
322322
if (where) {

0 commit comments

Comments
 (0)