Expose JSON schema validations for each mutation/query and provide hooks to easily consume the schemas #3357
capaj
started this conversation in
RFC / Ideas
Replies: 1 comment
-
BTW @StefanTerdell do you use react-jsonschema-form ? Is that your usecase for the json schemas created from zod? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Writing a react app on top of trpc is nice and easy, but there are still tedious manual steps one must do.
For me by far the biggest one is client side forms, especially for stuff like backoffice admin dash, where the UI does not have any design and I don't care about how it will look like.
I was thinking of how to solve this most elegantly. Zod is great, but it cannot be exposed over network-you cannot serialize it easily. The next best thing is JSON schema.
So how about taking:
https://github.com/StefanTerdell/zod-to-json-schema#readme
and making sure that it can be fetched over a for any query/mutation in any given router?
My dream client side api would be something like:
Where form would render using the https://github.com/rjsf-team/react-jsonschema-form.
This is probably something not everyone will want on the API, so it would make sense to keep it configurable and optional on backend.
Beta Was this translation helpful? Give feedback.
All reactions