I just want to get a gauge of what people think is the best practice for doing validation of user input fileds (such as url or email address) on the server with a graphql / orm setup.
My application is using apollo server / gql and sequelize as the orm.
I've seen some who do validation on the model in sequelize and other examples of validation in the graphql resolver with with a validation library or using custom scalars.
Is any one way preferable? Thanks.
Input validation is some kind of AOP, like authentication and authorization. From my knowledge, there are five ways can do this.
if (validationPass) {...} else {..}
- Too verbose, keep the resolver thin is a best practice. Because It's some kind of route layer. Not recommendinfo
parameter to get the GraphQL operation. Not recommendIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With