SafeQL ❤️ Prisma
SafeQL is compatible with Prisma which supports raw queries as well, and very straightforward to use!
DEMO
Check out @ts-safeql-demos/prisma for a working example.
js
// eslint.config.js
import safeql from "@ts-safeql/eslint-plugin/config";
import tseslint from "typescript-eslint";
export default tseslint.config(
// ...
safeql.configs.connections({
// ... (read more about configuration in the API docs)
targets: [
// this will lint syntax that matches
// `prisma.$queryRaw` or `prisma.$executeRaw`
{ tag: "prisma.+($queryRaw|$executeRaw)", transform: "{type}[]" },
],
})
);
Once you've set up your configuration, you can start linting your queries:
typescript
import { Prisma, PrismaClient } from "@prisma/client";
const prisma = new PrismaClient();
// Before:
const query = prisma.$queryRaw`SELECT idd FROM users`;
~~~ Error: column "idd" does not exist
// After bug fix:
const query = prisma.$queryRaw`SELECT id FROM users`;
~~~~~~~~~~~~~~~~ Error: Query is missing type annotation
// After: ✅
const query = prisma.$queryRaw<{ id: number; }[]>`SELECT id FROM users`;