Closed sam-lewis closed 1 year ago
I believe we're seeing this issue as well.
Could the Prisma team add findUniqueOrThrow
to their list of "dataloader approved" funcs to resolve this? Or would typegraphql-prisma need to generate slightly different models? I've been reading through the fluent API, could that be used here?
I was able to get around this in my specific implementation, and by using Prisma's Fluent API I got a 97% perf boost (!!!).
IDK how hard it would be to get the generated code to make use of the Fluent API, but if you see an easy way that might help this category of issue.
https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#fluent-api
I was able to get around this in my specific implementation, and by using Prisma's Fluent API I got a 97% perf boost (!!!).
How does that compare to manually editing the generated relation resolver code to use findUnique()?
How does that compare to manually editing the generated relation resolver code to use findUnique()?
Oh yeah actually really good as well, probably here the only value of the Fluent API was to get the dataloader to pay attention, then.
For reference, I am managed to handle it forcibly with middleware, as shown in the following link. π https://github.com/prisma/prisma/issues/18838#issuecomment-1547295065
Closing as looks like it's fixed by https://github.com/prisma/prisma/issues/16625 π
@sam-lewis If the issue still occurs, please let me know π
Describe the Bug It appears that the switch to
findUniqueOrThrow()
in https://github.com/MichalLytek/typegraphql-prisma/commit/3ea20f65b030311d384a457c62b84deab1fc1d46 has introduced an N+1 select issue.I have observed that Prisma's built-in dataloader batches
findUnique()
queries but notfindUniqueOrThrow()
queries resulting in N+1 selects in recent versions of typegraphql-prisma.To Reproduce
npm install
npm run generate
npm start
Expected Behavior Fewer select statements against the database as seen with previous versions (see logs below)
Logs With typegraphql-prisma 0.25.0:
With typegraphql-prisma 0.23.2:
Environment:
typegraphql-prisma
version 0.25.0Additional Context Nice work on the project, its awesome :-)