-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DSG: @Transform decorators #1291
Comments
@EndersDev thanks for reporting I will look into the first one. |
@EndersDev can you please share the error you receive regarding the @trasnform decorator? By the reference of the decorator using this code
is just a shorthand of this
which should work, as it is a function that gets the value as the first parameter and executes JSON.parse on the value I also tested it and didn't get any errors. |
This issue was closed because it has been inactive for more than 30 days |
Describing the bug
On the "WhereInput.ts" files the decorator
@Transform(JSON.parse)
does not work.On "schema.prisma", the decorator
@reference
need an property that it does not have, references, with its id.Fixing
Considering that it is a function that needs an non-string type and the inside of @Transform needs to be a function I was able
to make it work replacing that statement with
@Transform(field => JSON.parse(field.value))
So I was able to substitute
@relation(fields: [sellerId])
by@relation(fields: [sellerId], references: [id])
.Context
The properties of field variable are [value, obj, key, type], I'm new to back-end programming so I yet don't know which one to use, there for, I'll use "value" and then if I find any errors on the application I'll try the others (by the name I guess that the only other possible is obj).
The text was updated successfully, but these errors were encountered: