Closed filipstefansson closed 1 year ago
That would be nice to have! Even without merging validate functions. Do you need help with getting this shipped?
@patryk-smc That would be great, thanks!
I like that feature!
You actually can merge yup schemas using concat()
for extending or shape()
overriding object()
schemas.
Few examples can be found in this ticket: jquense/yup#232
For this library it would probably make sense to use concat()
to merge two (or more) schemas.
I played arround with it a little bit and it actually worked for the most part as expected.
I also opened an issue in yup's repo because there seems to be a bug when chaining optional()
and required()
: jquense/yup#1535
this is a great addition @filipstefansson I'm also trying to use it with the inputObjectType
.
Looks like https://github.com/graphql-nexus/nexus/pull/799 has been merged. What's currently missing to get this one main? 🎉
Is this project actively maintained? I would also love this feature.
What this PR is about
Adds support for generic validations through
inputObjectType
. Thevalidate
method here needs to return a function that returns anObjectShape
instead of a function, because we can't pass args and context here:This will then get called whenever
UserInput
is used.Work left to do
A field currently only support one validation function, and since yup schemas can't be merged we will need to support passing an array of validation functions so we can call all of them. Today, this scenario wouldn't work:
The idea is that our resolver should be able to run both validations.
Blockers
The implementation works, but the types are currently broken and needs this PR to work: https://github.com/graphql-nexus/nexus/pull/799