G’day, folks. I’m noticing that, when I run `findU...
# orm-help
m
G’day, folks. I’m noticing that, when I run
findUnique
and no records match my query, I get an internal server error. I can’t even prevent this from happening by specifying
rejectOnNotFound: false
. It happens to matter what.
Copy code
Invalid `prisma.product.delete()` invocation:


  An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
Error:
Invalid `prisma.product.delete()` invocation:


  An operation failed because it depends on one or more records that were required but not found. Record to delete does not exist.
    at RequestHandler.request (/Users/meh/codebase/blah/blah-api/node_modules/@prisma/client/runtime/index.js:49022:15)
    at PrismaService._request (/Users/meh/codebase/blah/blah-api/node_modules/@prisma/client/runtime/index.js:49919:18)
    at ProductsService.deleteProduct (/Users/meh/codebase/blah/blah-api/src/products/products.service.ts:27:12)
    at ProductsResolver.deleteProduct (/Users/meh/codebase/blah/blah-api/src/products/products.resolver.ts:45:12)
    at target (/Users/meh/codebase/blah/blah-api/node_modules/@nestjs/core/helpers/external-context-creator.js:77:28)
    at /Users/meh/codebase/blah/blah-api/node_modules/@nestjs/core/helpers/external-proxy.js:9:24
1
t
Hey Michael, This seems to be a
delete
call and not
findUnique
based on the logged info.
delete
raises a PrismaClientKnownRequestError when the record does not exist. Perhaps you could show the relevant code? Maybe you’re accidentally calling the wrong function.
m
Tasin, thank you. It turned out that my NestJS application had cached some old code; deleting the
dist
directory and recompiling the application did the trick.
t
Awesome, happy to help 😄