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.

Weekly downloads
11.9M
Version
6.0.1
License
MIT
Updated
Nov 12, 2026

coreutilities

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 ...
  ]
})