PrismaP
Prisma8mo ago
17 replies
Max

Basic Prisma Optimize Is Not Working

Hi, I'm am trying to debug some bad query performance in our application. I was going to use prisma optimize, but no matter what I it absolutely refuses to push anything the website.

I have a VERY minimal example that does not work:

import {PrismaClient} from './generated/prisma';
import {withOptimize} from '@prisma/extension-optimize';

const prismaClient = new PrismaClient().$extends(withOptimize({apiKey: '<REDACTED>'}));
prismaClient.user.findFirst({
    where: {
        fullName: {
            contains: 'hello world',
            mode: 'insensitive'
        }
    }
});


generator client {
  provider = "prisma-client-js"
  output   = "../src/generated/prisma"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id       Int    @id
  fullName String
}


I get the output:
┌─────────────────────────────────┐
│ See your Optimize dashboard at: │
│ https://optimize.prisma.io      |
└─────────────────────────────────┘

when running it with
npx tsx ./src/index.ts


In my actual app, I do get one query to show up, so its not like its not authenticating or anything. That one query is a $queryRawTyped

I am using prisma v6.12.0, I also tried v6.6.0. Does Optimize not work with v6.6.0+? Do I just need to downgrade the optimize version? I am using the latest, 2.0.0.
Was this page helpful?