useValidationRule

useValidationRule

Package nameWeekly DownloadsVersionLicenseUpdated
@envelop/coreDownloadsVersionLicenseAug 20th, 2024

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