graphql-constraint-directive

JSON →
library 6.0.0 ·javascript
verified Jun 7, 2026

Validate GraphQL input fields using @constraint directive, inspired by the Constraints Directives RFC and OpenAPI. Current stable version is 6.0.0, with frequent releases tracking GraphQL ecosystem changes. Key differentiator: works as a schema wrapper (modifies schema, validates both input and response) or as server plugins (Envelop, Apollo) that keep schema unmodified but only validate incoming queries. Supports constraints like minLength, maxLength, format (regex), minimum, maximum, pattern, etc. Requires peer dependency graphql >=14.0.0. Ships TypeScript definitions.