NestJs + Prisma Optimize
Hello everyone!
I would like to ask if anyone has managed to integrate a NestJs server with the Optimize tool and how.
I have tried this instantiation part in a few ways
such as adding it to the prismaService, using useValue and useFactory in the module and even instantiating it in the function that performs the query.
I receive the return log that Optimize is connected
"See your Optimize dashboard at: https://optimize.prisma.io"
, and it does not display any errors, but no information about any query made to the Optimize platform is received.
versions
19 Replies
Hey @Txt 👋
Can you share the link to your repository if it's open source so that we can debug?
Some other users have also reported the same issue where Optimize wasn't working with a NestJS app.
Hey @Nurul (Prisma) , thanks for the reply,
Unfortunately, the project is private, so I can only share some snipped codes.
But I can create a simple POC based on this project to share, and maybe I’ll find something as well.
As soon as I have it, I’ll share it here, but if you have any tips on implementing NestJS with Optimize, they’re welcome.
Oh, and one more thing, I tested by adding the Accelerator, and the caching system worked fine, everything's normal on the platform, but nothing happened with Optimize.
A simple POC would be great 🙏
Same issue here, also using Nest.js
Have you confirmed it works with Nest.js @Nurul (Prisma) ?
I am having the same issue with Next.js (not Nest.js) server components. The same code works fine when invoking via node, but in Next.js routes everything is setup but nothing is sent to the dashboard.
Nevermind, I figured it out: On next.js it does not work in combination with Next.js's own instrumentation https://nextjs.org/docs/app/building-your-application/optimizing/instrumentation 😦
@Eric Not yet, Is your repository open source? Can you share the link?
No it's private.
I don't do much different from the official prisma <> nestjs page, so would be easy to test: https://docs.nestjs.com/recipes/prisma
Documentation | NestJS - A progressive Node.js framework
Documentation | NestJS - A progressive Node.js framework
Nest is a framework for building efficient, scalable Node.js server-side applications. It uses progressive JavaScript, is built with TypeScript and combines elements of OOP (Object Oriented Programming), FP (Functional Programming), and FRP (Functional Reactive Programming).
If prisma optimize does as advertised, we will most likely be a paying customer. But right now completely blocked
Thanks for confirming. I'll try creating an example app with NestJS + Prisma today and check if I can reproduce this.
I'll share the findings with our Optimize team and get back to you with an update.
I have created this reproduction and can see that the queries are not showing in the Optimize Dashboard.
https://github.com/nurul3101/Optimize-NestJS
I have shared this with our team and will get back with an update.
thank you for looking into this @Nurul (Prisma) , really appreciate it! Looking forward to hear what the team say
@Eric @Txt We were able to make Optimize work with Optimize. Can you instantiate PrismaClient in
OnModuleInit
like this:
https://github.com/nurul3101/Optimize-NestJS/blob/main/src/prisma.service.ts
This would make sure that queries are displayed in Optimize Dashboard.GitHub
Optimize-NestJS/src/prisma.service.ts at main · nurul3101/Optimize-...
Contribute to nurul3101/Optimize-NestJS development by creating an account on GitHub.
@Nurul (Prisma) I have also facing the same issue on my backend, I am using Nest.js, Prisma and swagger.
This is my databaseService code
I'm getting the log that
see your optimize dashboard
but not getting anything in the prisma optimize dashboard when running the api's in the swagger.I have the same issue, and the suggested code doesn't work for me either :).
Any updates on this?
@tl;dr Do you mind sharing the link to your GitHub repository?
Yes unfortunately, it's a commercial product :/. Is there a way to check from my localhost, if I even reach the Prisma backend for the optimize service?
When I go to the UI on https://optimize.prisma.io, theres just nothing comming in.
And I have my server running localhost making queries ofc.
And I get this, so I guess something is working
It would be great if you can share a minimal reproduction of this issue. I'll be able to then share it with our Optimize team to figure out what's going on.
This is my service: `
Hmm, I guess I'm going to have to bail on this then :/.. Is there an open issue somewhere I can follow so I can get back to this at some point?
It would be too time consuming to begin to pull the app appart etc., and with no guarantee of a positive outcome, I can't make that investment unfortunately :/.
Time better spend looking into the performance issues in another way.
I guess theres no open issue, thanks for the efford. out.
No worries, I'll try to reproduce based on the service file you shared above.
Regarding the Issue, I can tag you in this conversation if I have an update.