GraphQL validation rule to prevent batched queries and mutations, mitigating denial-of-service and brute-force attacks. Current version is 2.0.2, released with TypeScript type definitions and supporting GraphQL v16+. The rule limits the number of root operation fields per request (default 1) and supports custom error messages. Unlike rate-limiting middleware, this is a validation-only approach that integrates directly into GraphQL execution pipelines (e.g., express-graphql, graphql-yoga, graphql-http). Also offers an optional Envelop plugin.
npm install graphql-no-batched-queriesNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to integrate graphql-no-batched-queries as a validation rule in an express-graphql server, allowing only 1 operation per request.
Upgrade to GraphQL v16.3.0 or later.
Update import to 'graphql-no-batched-queries/envelop-plugin'.
Use in combination with graphql-no-alias directive to prevent duplicate field aliases.
Ensure you pass a valid GraphQLSchema object to the GraphQL server.
Upgrade to graphql v16.3.0 or later.
Set `allow` to a positive integer (e.g., 1, 2, ...).