Temporary solution (bad): change import { PrismaClient } from "@prisma/client/edge"; to import { PrismaClient } from "@prisma/client";
When i tried to use Prisma.join() on raw query using edge client i got an error: TypeError: The "payload" argument must be of type object. Received null Example query:
await prisma.$queryRaw` SELECT "id" FROM "table" WHERE "x" = ${String(query)} AND "y" = ${String(query1)} AND "z" IN (${Prisma.join(stringsArray)}) AND "i" IN (${Prisma.join(stringsArray)}) AND "j" IN (${Prisma.join(stringsArray)}) LIMIT ${number}`
await prisma.$queryRaw` SELECT "id" FROM "table" WHERE "x" = ${String(query)} AND "y" = ${String(query1)} AND "z" IN (${Prisma.join(stringsArray)}) AND "i" IN (${Prisma.join(stringsArray)}) AND "j" IN (${Prisma.join(stringsArray)}) LIMIT ${number}`
Any idea how to make it work on edge?
Solution
Hi @Papa Smerf
The edge client is a stripped down version and may not support the Prisma.join() api. Rewriting the raw query without using Prisma.join() should resolve this issue.
await prisma.$queryRaw` SELECT "id" FROM "table" WHERE "x" = ${String(query)} AND "y" = ${String(query1)} AND "z" = ANY(${stringsArray}::text[]) AND "i" = ANY(${stringsArray}::text[]) AND "j" = ANY(${stringsArray}::text[]) LIMIT ${number}
await prisma.$queryRaw` SELECT "id" FROM "table" WHERE "x" = ${String(query)} AND "y" = ${String(query1)} AND "z" = ANY(${stringsArray}::text[]) AND "i" = ANY(${stringsArray}::text[]) AND "j" = ANY(${stringsArray}::text[]) LIMIT ${number}
The raw query example assumes you are using Postgres. Let me know if this helps.