Input objects support default values
Code-Hex opened this issue · 4 comments
Code-Hex commented
Input objects support default values and we'd like to get this supported in the generated schema: http://spec.graphql.org/June2018/#sec-Input-Objects
enum PageType {
PUBLIC
BASIC_AUTH
}
input PageInput {
pageType: PageType! = PUBLIC
greeting: String = "Hello"
score: Int = 100
ratio: Float = 0.5
isMember: Boolean = true
}Should be able to generate the following:
export const PageTypeSchema = z.nativeEnum(PageType);
export function PageInputSchema(): z.ZodObject<Properties<PageInput>> {
return z.object({
pageType: PageTypeSchema.default("PUBLIC"),
greeting: z.string().default("Hello").nullish(),
score: z.number().default(100).nullish(),
ratio: z.number().default(0.5).nullish(),
isMember: z.boolean().default(true).nullish()
})
}
bramvanderholst commented
@Code-Hex I'm looking to pick this up where the original PR left off.
If I implement the other 2 schema's, will this be ready to be merged or are other changes required?
Code-Hex commented
@bramvanderholst I can merge the PR if you implement the other schema's.
If I implement the other 2 schema's, will this be ready to be merged or are other changes required?
bramvanderholst commented