Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 817 Bytes

use-validation-rule.md

File metadata and controls

25 lines (22 loc) · 817 Bytes

useValidationRule

This plugin is the simplest plugin for adding a validation rule to your GraphQL schema. You can specify any function that conforms to the ValidationRule type.

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine, useValidationRule } from '@envelop/core'
import { depthLimit } from '@graphile/depth-limit'

const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    useValidationRule(
      depthLimit({
        maxDepth: 12,
        maxListDepth: 4,
        maxSelfReferentialDepth: 2
      })
    )
    // ... other plugins ...
  ]
})