1.5.0 • Published 3 years ago

@winninjs/graphql-io-utils v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

graphql-io-utils

Utilities directives and scalar types to help on graphql input/output validation and sanitization.

Installation

npm i @winninjs/graphql-io-utils

Scalar

Email

Represents a valid email

type Query{
  
  email:Email! # Returns a non-null valid Email
  sendEmail(email:Email):Email # Send and returns a valid Email
}

URL

Represents a valid URL

type Query{
  
  url:URL! # Returns a non-null valid URL
  sendURL(url:URL):URL # Send and returns a valid URL
}

PII

Redacts PII info on string

type Query{
  
  piiData:PII! # Returns a redacted PII string
}

Directives

It includes two directives:

@stringUtils

Lets you run a method over a string input or output

type Query{
  
  returnTrimmedAndUpper:String! @stringUtils(stringMethods:["trim","toUpperCase"]) # runs trim and toUpperCase on returned String
  
  sendTrimmedAndLower(trimmedAndLower:String!@stringUtils(stringMethods:["trim","toLowerCase"])):String! # runs trim and toLowerCase on query argument

}

@validate

Runs common validations over input

type Query{
  email(value:String! @validate(email:true)):String! #validates if the value is an valid email
}

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
1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.5.0

3 years ago

1.4.1

3 years ago

1.1.4

3 years ago

1.4.0

3 years ago

1.3.0

3 years ago

1.0.0

3 years ago