You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow configuration of zod optional/null type #308
I'd love to use this library but since we redefine inputMaybeValue: 'T | undefined' in the graphql-codegen configuration, it's incompatible with the .nullish() that gets added to the zod schema when using graphql-codegen-tyespcript-validation-schema.
It would be great if we could have a configuration such as zodOptionalType that allowed us to specify optional or nullish.
Hey @Code-Hex ! No worries.
Yea - I'm looking for an ability to customize the nullish values generated by graphql-codegen-typescript-validation-schema.
An example API that would be nice:
I'm also having this issue, my current workaround is to run sed -i 's/\.nullish()/.optional()/g' in afterAllFileWrite but it feels very hacky and prone to errors.
Activity
Code-Hex commentedon Apr 16, 2023
@peniqliotuv Hi 👋
I'm sorry to delay this reply.
Could you tell me how to do this?
peniqliotuv commentedon Apr 18, 2023
Hey @Code-Hex ! No worries.
Yea - I'm looking for an ability to customize the nullish values generated by
graphql-codegen-typescript-validation-schema.An example API that would be nice:
This value would default to
nullish.The behavior of
nullishwould be akin to what's currently in the plugin today.Providing
nullProviding
undefinedI omitted the
yupequivalents for simplicity's sake, but hopefully this makes it clearer!almereyda commentedon Nov 26, 2023
I think instead of providing
null, this should benullable>.nullable().Also to provide undefined, one needs to write
optional, so that renders to.optional().niklasholm commentedon Nov 1, 2024
I'm also having this issue, my current workaround is to run
sed -i 's/\.nullish()/.optional()/g'inafterAllFileWritebut it feels very hacky and prone to errors.Code-Hex commentedon Apr 25, 2026
Fixed in #1423. Zod optional/null handling is now configurable through zodOptionalType, with nullishBehavior accepted as an alias.