graphql-io-utils
Utilities directives to help on graphql input/output validation and sanitization.
Installation
npm i @winninjs/graphql-io-utils
It includes two directives:
1 - stringUtils, which lets you run a method over a string input or output
type Query{
returnTrimmedAndUpper:String! @stringUtils(stringMethods:["trim","toUpperCase"])
sendTrimmedAndLower(trimmedAndLower:String!@stringUtils(stringMethods:["trim","toLowerCase"])):String!
}
2 - validate, runs common validations over input
type Query{
email(value:String! @validate(email:true)):String!
}
Currently supports the following validations:
- email
- url
- alpha
- alphaNum
- alphaDash
- digits
- ip
- hex
- lt
- lte
- gt
- gte
- stringLengthLT
- stringLengthLTE
- stringLengthGT
- stringLengthGTE
- stringLengthEquals
- notEmpty
- startsWith
- endsWith
- contains
- notContains