Title
j

Jakub Figlak

12/29/2021, 1:47 PM
How can I catch this kind of error?
Unknown arg `country` in data.country for type RegionUncheckedUpdateInput. Did you mean `countryId`? Available args:
type RegionUncheckedUpdateInput {
  id?: String | StringFieldUpdateOperationsInput
  name?: String | StringFieldUpdateOperationsInput
  createdAt?: DateTime | DateTimeFieldUpdateOperationsInput
  updatedAt?: DateTime | DateTimeFieldUpdateOperationsInput
  countryId?: String | StringFieldUpdateOperationsInput
}
This is probably not
PrismaClientKnownRequestError
cause it's missing my nest filter.
m

Muhannad

12/29/2021, 2:09 PM
in your prisma service
const { PrismaClient, Prisma } = require('@prisma/client');
In your error
middleware
catch these errors
error instanceof Prisma.PrismaClientKnownRequestError ||
error instanceof Prisma.PrismaClientValidationError
......etc
are you using
nestjs-prisma
?
j

Jakub Figlak

12/29/2021, 2:15 PM
No, I'm not using this, should I? 😄
m

Muhannad

12/29/2021, 2:20 PM
you need to add another method to catch
Prisma.PrismaClientValidationError
j

Jakub Figlak

12/29/2021, 2:23 PM
Sure, thank you. Gonna try this later. I just didn't know how to find the type of this particular error:)
👍 1
Btw, since I have you here - do you have any examples of real life nest/prisma or just express/prisma projects? I need some inspirations:)
m

Muhannad

12/29/2021, 3:01 PM
you can start from here … https://www.prisma.io/nestjs

https://www.youtube.com/watch?v=mmbd5hcQUaY

https://github.com/notiz-dev/nestjs-prisma-starter/tree/main/src
j

Jakub Figlak

12/29/2021, 3:22 PM
Yeah, I went through this tutorial and it’s great:) But I’m looking for something more complex, with different modules, some middleware etc. But okay, if there’s nothing like that I’ll Just go step by step.
m

Muhannad

12/29/2021, 3:25 PM
i have , but it is not open source project , sorry
j

Jakub Figlak

12/29/2021, 5:56 PM
Ok, thanks for your help:)
In case of anyone reading this later - catching the error is one thing but the best solution I found to this problem is to strip out any unwanted properties from the request earlier. It can be accomplished by passing ‘whitelist: true’ to validation pipe config.