Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "drizzle-graphql",
"type": "module",
"author": "Drizzle Team",
"version": "0.8.5",
"version": "0.8.6",
"description": "Automatically generate GraphQL schema or customizable schema config fields from Drizzle ORM schema",
"scripts": {
"build": "pnpm tsx scripts/build.ts",
Expand Down
1 change: 1 addition & 0 deletions src/util/data-mappers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const remapToGraphQLCore = (
);
}
if (column.columnType === 'PgGeometry' || column.columnType === 'PgVector') return value;
if (column.columnType === 'PgJson' || column.columnType === 'PgJsonb') return JSON.stringify(value);

return value.map((arrVal) => remapToGraphQLCore(key, arrVal, tableName, column, relationMap));
}
Expand Down
7 changes: 6 additions & 1 deletion tests/pg.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ beforeEach(async () => {
await ctx.db.execute(sql`CREATE TABLE IF NOT EXISTS "posts" (
"id" serial PRIMARY KEY NOT NULL,
"content" text,
"author_id" integer
"author_id" integer,
"post_config" jsonb
);`);

await ctx.db.execute(sql`CREATE TABLE IF NOT EXISTS "users" (
Expand Down Expand Up @@ -217,11 +218,13 @@ beforeEach(async () => {
id: 1,
authorId: 1,
content: '1MESSAGE',
postConfig: ['config1', { configName: 'hello', configValue: 123 }],
},
{
id: 2,
authorId: 1,
content: '2MESSAGE',
postConfig: ['config2', { configName: 'hello', configValue: 123 }],
},
{
id: 3,
Expand Down Expand Up @@ -299,6 +302,7 @@ describe.sequential('Query tests', async () => {
id
authorId
content
postConfig
}
}
`);
Expand Down Expand Up @@ -330,6 +334,7 @@ describe.sequential('Query tests', async () => {
id: 1,
authorId: 1,
content: '1MESSAGE',
postConfig: '["config1",{"configName":"hello","configValue":123}]',
},
},
});
Expand Down
2 changes: 2 additions & 0 deletions tests/schema/pg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
date,
geometry,
integer,
jsonb,
pgEnum,
pgTable,
serial,
Expand Down Expand Up @@ -53,6 +54,7 @@ export const Posts = pgTable('posts', {
id: serial('id').primaryKey(),
content: text('content'),
authorId: integer('author_id'),
postConfig: jsonb('post_config'),
});

export const usersRelations = relations(Users, ({ one, many }) => ({
Expand Down