Skip to content

Allow transform after .default in zod #806

@MaLiN2223

Description

@MaLiN2223

Currently, due to limitation of the zod framework, all default properties become nullable which causes an issue for us. The apparent solution is to add a transform call after the .default(, e.g. z.boolean().default(false).transform(option.fromNullable)

I know that I can do
scalarSchemas: { Boolean: "z.boolean().transform(option.fromNullable)", },
but this applies the transformation before .default

Looking at the code (index.ts for zod), I can see that the default is hardcoded to be the last one.

Would it be possible to configure the plugin to generate something after .default?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions