-
-
Notifications
You must be signed in to change notification settings - Fork 51
Yup schema won't add 'nullable' to optional fields. #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@adamwdennis Thanks to open issue! Could you show me your GraphQL schema which is generated from your ts file? Thanks. |
Hi @Code-Hex -- thanks for the quick response here... I've updated the description, per your request, with a |
@adamwdennis Thanks. I confirmed the problem. https://codesandbox.io/s/yup-forked-z4fgyw?file=/src/index.js I will fix this |
I remember why this is happening. If this fix is made now, primitives will not have the problem, but arrays will not compile. What do you think, should we wait until the 1.0.0 release? |
Note (my question issue for next): jquense/yup#1658 |
Thanks for the above. Is |
@adamwdennis Yes, I think so. zod is good one.
I'm sorry this plugin does not support for zup.
|
@Code-Hex Hi. Thanks for the amazing library btw! Does this still a progressing issue? I currently have a input like below. (forgive me for using a language-specific implementation input object) input_object :update_input do
field(:id, non_null(:id))
field(:email, :string)
field(:name, :string)
end This is what codegen generated for me which is correct to my input defined on the server. export type UpdateInput = {
id: Scalars["ID"] # ID is required
name?: InputMaybe<Scalars["String"]> # this is nullable
email?: InputMaybe<Scalars["String"]> # this is nullable
} This is what I got from your codegen. export function UpdateInputSchema(): yup.SchemaOf<UpdateInput> {
return yup.object({
id: yup.string().defined(),
email: yup.string(),
name: yup.string(),
})
} These are the results I expected. I might not even need the return yup.object({
id: yup.string().defined(),
email: yup.string().nullable(),
name: yup.string().nullable(),
}) could you help me achieve this? |
@qwexvf Hi 👋 I think the code that is you want will be occurred compilation error by return yup.object({
id: yup.string().defined(),
email: yup.string().nullable(),
name: yup.string().nullable(),
}) By the way, Could you share me your GraphQL schema (only UpdateInput)? |
I think this problem has been resolved at #351 |
When I run the generator, my Yup schema does not add
.nullish()
to any optional fields.my-type.ts
schema.graphql
generated-operations.ts
Expected Result
generated-validation-schema.ts
Actual Result
generated-validation-schema.ts
The text was updated successfully, but these errors were encountered: