Only single validation sent to client at a time
See original GitHub issueBug report
- I have checked other issues to make sure this is not a duplicate.
Describe the bug
Note: not sure if this is a bug or working as intended.
Consider a validation like this:
inputRule((yup) => {
return yup.object({
email: yup.required(),
username: yup.required(),
password: yup.required(),
})
})
If I invoke the graphql mutation that uses this yup validation, with no input arguments, I will only see one validation error at a time. This makes it difficult to build a nice user experience on things like login forms, etc, since the user will only see one issue at a time.
Expected behavior
I expect the graphql api to return three validations, ideally with the path to the property associated with each validation error. Something along the lines of “email is required”, “username is required”, and “password is required”.
Actual behaviour
Only one validation at a time is returned.
Additional context
This behavior can be controlled on the yup
side of things via the abortEarly
validation option, e.g. yup.validate(schema, { abortEarly: false })
.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top GitHub Comments
🎉 This issue has been resolved in version 7.0.0 🎉
The release is available on:
Your semantic-release bot 📦🚀
Hey 👋,
Excuse my absence, I had my final examinations, but I am up and running now. I have done some experimentation and I propose the following.
inputRule
should be extended so that it exposesoptions
which will include all available Yup options.Furthermore, we should somehow enable the possibility of manipulating the errors list returned by Yup since I cannot find a better default alternative. I have attached an example of error object and its complement on GraphQL side below so you get the idea of the data that we are dealing with.
Perhaps you have any idea how we could make this more approachable?