Zod doesn't pass data to input relation field. (create, connectOrCreate, connect fields) #28
-
Hi guys, shout out to @omar-dulaimi for this great lib. Currently i am developing admin panel and using prisma-trpc-generator to generate all endpoints. I am trying to create relations between entities. So what i am doing is sending For example:
But when i send this request, relation fields (openGraphImage, coverImage, category) are empty in input.
I did some digging and looked into zod schema that is generated and i think the problem is this schema:
Because zod can't distinguish between these 3 objects, it won't match any of these and leave the final field empty. What is weird that it doesn't throw any errors that the union is invalid or something. Does anyone know if this is a bug or that i am sending data wrong way? Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @John-Hejzlar I apologize for forgetting to respond. Glad that you like this project. Also, please note that this issue should be fixed since If any schema related problem arises, feel free to open a new issue here: https://github.com/omar-dulaimi/prisma-zod-generator Don't forget to star this project :) |
Beta Was this translation helpful? Give feedback.
-
Just tested it and seems to be working correctly. Thanks a lot |
Beta Was this translation helpful? Give feedback.
Hey @John-Hejzlar
I apologize for forgetting to respond. Glad that you like this project.
Also, please note that this issue should be fixed since
0.4.2
. So just updating to the latest version would fix it for you.If any schema related problem arises, feel free to open a new issue here: https://github.com/omar-dulaimi/prisma-zod-generator
Since that's where the schemas are get generated!
Don't forget to star this project :)