GraphQL directive and validation library to limit alias fields on queries and mutations, preventing batch attacks. Current stable version is 3.0.3, actively maintained with regular releases. It provides a @noAlias directive that can be applied to GraphQL types or fields, with customizable alias limits. Key differentiators: supports both schema directive and imperative configuration, includes error message customization, and offers an optional Envelop plugin for integration with Envelop-based servers. Requires graphql ^16.2.0.
npm install graphql-no-aliasNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows basic setup with @noAlias directive on Mutation type, limiting aliases to 1. Demonstrates schema construction and validation rule integration.
Use import() or switch to ES modules. If CJS required, use require('graphql-no-alias/cjs').Always specify 'allow' explicitly to avoid confusion. Example: @noAlias(allow: 2)
Call createValidation({ fieldConfig: ... }) with proper configuration per field or type.Migrate to imperative configuration for improved performance. See README examples.
Reduce number of aliases or increase the 'allow' value in @noAlias directive or imperative config.
Use import { createValidation } from 'graphql-no-alias' (ESM) or const { createValidation } = require('graphql-no-alias/cjs').Ensure you interpolate ${typeDefs} into your schema string before building it.Apply @noAlias only on Query, Mutation, or their fields, and ensure schema defines them as root types.