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.
- Package
- @envelop/core
- Weekly downloads
- 5.5M
- Version
- 5.6.1
- License
- MIT
- Updated
- Sep 16, 2026
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 ...
]
})