Replies: 1 comment 1 reply
-
This is not a NestJS oriented repo. They have their own implementation of GraphQL, although similar to this. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
by resuing zod schema, can make zod as single source of truth for client schema.
it's also possible to add a middleware for validate, but I dont want to, I prefer doing the validate at the service level.
zod can also create NestJS's DTO, that make generate openapi easier and sync the fields between the gql and restful.
zod v4 has built-in support for jsonschema, that make create/instrospect types eaiser. I used to generate typebox from ts types, but now I juse use zod to define schema is enough.(typebox is almost equal to jsonschema).
The result
This is how to create dynamic types from jsonschema
Some factory https://github.com/wenerme/wode/blob/main/packages/wener-nestjs/src/type-graphql/resource/factory.ts
I used mixin for resuing fields before https://github.com/wenerme/wode/tree/main/packages/wener-nestjs/src/type-graphql/mixins
but zod schema reusing is better and easier.
Beta Was this translation helpful? Give feedback.
All reactions