Jackson Kasi
Jackson Kasi
Explore posts from servers
DTDrizzle Team
Created by Jackson Kasi on 10/22/2024 in #help
Issue: Error during `db:push` - TypeError in Drizzle Kit with PostgreSQL
No description
3 replies
DTDrizzle Team
Created by Jackson Kasi on 8/17/2024 in #help
Issue with drizzle-graphql Entities Not Working Well with GraphQL
No description
3 replies
DTDrizzle Team
Created by Jackson Kasi on 8/17/2024 in #help
Help Needed: Error with Arguments in GraphQL Resolver Using Drizzle ORM, Serverless, and TypeScript
Hi Drizzle Community, I'm running into an issue with GraphQL and Drizzle ORM while working on a serverless project using TypeScript. I've set up my environment with the following key components: - Environment: Serverless Framework - Language: TypeScript - ORM: Drizzle ORM - GraphQL: Apollo Server with @apollo/server - Database: PostgreSQL (using drizzle-orm/postgres-js) Problem Description I'm encountering the following error when trying to run my serverless application:
✖ Unhandled exception in handler 'server'.
✖ Query.userProfile args must be an object with argument names as keys.
Error: Query.userProfile args must be an object with argument names as keys.
at devAssert (...\graphql\jsutils\devAssert.js:12:11)
at ...\graphql\type\definition.js:793:32
...
✖ Unhandled exception in handler 'server'.
✖ Query.userProfile args must be an object with argument names as keys.
Error: Query.userProfile args must be an object with argument names as keys.
at devAssert (...\graphql\jsutils\devAssert.js:12:11)
at ...\graphql\type\definition.js:793:32
...
Context Here’s a simplified version of my code setup: user.schema.ts:
import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from "graphql";
import { drizzleEntities } from "@/db";
import { getUserProfile } from "./services/getUserProfile.service";

const userQuery = new GraphQLObjectType({
name: "UserQuery",
fields: {
userProfile: {
type: drizzleEntities.types.UsersItem,
args: {
authUserId: { type: new GraphQLNonNull(GraphQLString) },
},
resolve: async (_, args) => {
console.log(args);
const { authUserId } = args;
return getUserProfile(authUserId);
},
},
},
});

export { userQuery };
import { GraphQLObjectType, GraphQLNonNull, GraphQLString } from "graphql";
import { drizzleEntities } from "@/db";
import { getUserProfile } from "./services/getUserProfile.service";

const userQuery = new GraphQLObjectType({
name: "UserQuery",
fields: {
userProfile: {
type: drizzleEntities.types.UsersItem,
args: {
authUserId: { type: new GraphQLNonNull(GraphQLString) },
},
resolve: async (_, args) => {
console.log(args);
const { authUserId } = args;
return getUserProfile(authUserId);
},
},
},
});

export { userQuery };
5 replies
DTDrizzle Team
Created by Jackson Kasi on 8/16/2024 in #help
Help Needed: `UnhandledSchemeError: cloudflare:sockets` with Drizzle ORM and `runtime = "edge"`
Hi Drizzle community, I'm running into a problem while trying to deploy my Next.js API routes using Drizzle ORM with PostgreSQL. Everything works fine locally, but when I set export const runtime = "edge";, I encounter the following error during compilation:
⨯ cloudflare:sockets
Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.
Import trace for requested module:
cloudflare:sockets
./node_modules/.pnpm/[email protected]/node_modules/postgres/cf/polyfills.js
./node_modules/.pnpm/[email protected]/node_modules/postgres/cf/src/index.js
./src/db/index.ts
./src/app/api/[[...route]]/routes/register/index.ts
./src/app/api/[[...route]]/routes/index.ts
./src/app/api/[[...route]]/route.ts
⨯ cloudflare:sockets
Module build failed: UnhandledSchemeError: Reading from "cloudflare:sockets" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "cloudflare:" URIs.
Import trace for requested module:
cloudflare:sockets
./node_modules/.pnpm/[email protected]/node_modules/postgres/cf/polyfills.js
./node_modules/.pnpm/[email protected]/node_modules/postgres/cf/src/index.js
./src/db/index.ts
./src/app/api/[[...route]]/routes/register/index.ts
./src/app/api/[[...route]]/routes/index.ts
./src/app/api/[[...route]]/route.ts
My Setup: - Framework: Next.js - Database: PostgreSQL - ORM: Drizzle ORM with postgres package - Runtime: edge (Cloudflare Workers) - Key Code Snippet:
import { env } from "@/config/env";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

import * as schema from "./schema";

const client = postgres(env.DATABASE_URL);
export const db = drizzle(client, { schema, logger: true });

import { env } from "@/config/env";
import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";

import * as schema from "./schema";

const client = postgres(env.DATABASE_URL);
export const db = drizzle(client, { schema, logger: true });

Issue Summary: The error seems to stem from the postgres package when trying to use the edge runtime with Cloudflare Workers. It appears that Webpack cannot handle the cloudflare: scheme used in postgres/cf/polyfills.js. Questions: 1. Has anyone else encountered this problem when using Drizzle ORM with Cloudflare Workers and the runtime = "edge" setting? 2. Is there a recommended approach for using Drizzle ORM with PostgreSQL in Cloudflare Workers? Any advice or suggestions would be greatly appreciated! Thanks in advance for your help!
1 replies
DTDrizzle Team
Created by Jackson Kasi on 6/30/2024 in #help
Issue with Drizzle ORM and drizzle-kit push with Tembo Cloud PostgreSQL
No description
3 replies
DTDrizzle Team
Created by Jackson Kasi on 5/11/2024 in #help
Handling Aggregated Counts with GroupBy in Drizzle ORM: Requesting Community Insights
No description
2 replies
DTDrizzle Team
Created by Jackson Kasi on 4/20/2024 in #help
Need Help: `ilike` Function Not Returning Expected Results in Drizzle ORM
Hello Drizzle ORM Community! I'm currently working with Drizzle ORM in a TypeScript environment using PostgreSQL (specifically, Neon PostgreSQL) and I've encountered a small issue with querying user data using the ilike function for case-insensitive matching. I'm attempting to query tbl_users based on partial user names, but I'm not getting the expected results. Here's the snippet of my code where I implement the query:
const usersList = await db.query.tbl_users.findMany({
where: ilike(tbl_users.full_name, input.query), // todo: need to fix.
columns: {
full_name: true,
email: true,
},
});
const usersList = await db.query.tbl_users.findMany({
where: ilike(tbl_users.full_name, input.query), // todo: need to fix.
columns: {
full_name: true,
email: true,
},
});
I pass the query parameter as jack expecting to retrieve users with names like Jackson Kasi, but instead, I receive an empty array. According to the Drizzle ORM documentation, the ilike should work for PostgreSQL like so:
import { ilike } from "drizzle-orm";
db.select().from(table).where(ilike(table.column, "%llo wor%"));
import { ilike } from "drizzle-orm";
db.select().from(table).where(ilike(table.column, "%llo wor%"));
However, my current implementation doesn't seem to function as expected. Does anyone have experience with this function or can spot what I might be doing wrong? Any suggestions on how to properly use ilike with findMany or corrections to my approach would be greatly appreciated! Thank you in advance for your help!
3 replies
DTDrizzle Team
Created by Jackson Kasi on 4/18/2024 in #help
Help with SQL_PARSE_ERROR When Using Raw SQL Queries in Drizzle ORM with Sqlite ( truso db )
No description
1 replies
DTDrizzle Team
Created by Jackson Kasi on 4/10/2024 in #help
Issue Querying Table via Drizzle ORM with SQLite
No description
15 replies