Prisma with Accelerate TypeScript error
When I'm using Prisma with Accelerate, the Prisma types are not generated for the Accelerate extension. Trying to use
cacheStrategy
results in TS showing the following error:
I'm using SvelteKit and have the following setup:
src/app.d.ts
:
src/lib/server/prisma.ts
:
How can I fix this?5 Replies
Hey @Woman wearing Vision Pro 👋
This is strange. To confirm, you invoked
npx prisma generate
command, right?Yes I have, multiple times even
Is your repository open source?
If yes, can you share it with me so that I can try to reproduce and investigate?
I found a related discussion here:
https://github.com/prisma/prisma/discussions/22489
Does your query work if you directly define prisma client in the file in which you are invoking the query.
Something like
new PrismaClient().$extends(withAccelerate()).your_model_name.findUnique({ cacheStrategy: ... })
GitHub
Cannot use cacheStrategy because of 'Never' type · prisma prisma · ...
Question I want to query like this: await this.prismaService.site.findFirst({ where: { url: siteDomain, seller_name: '', }, cacheStrategy: { ttl: 60 }, }); But I get this error: TS2322: Typ...
It is open source but it's a pretty big project and requires a lot of external stuff to get it fully working. If you still want to take a look I'll send the repo.
It's not that the query fails, it's that typescript is complaining, so it's more an annoyance than something that's preventing caching/executing queries.
bump