
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
@envelop/rate-limiter
Advanced tools
This plugins uses [`graphql-rate-limit`](https://github.com/teamplanes/graphql-rate-limit#readme) in order to limit the rate of calling queries and mutations.
@envelop/rate-limiter
This plugins uses graphql-rate-limit
in
order to limit the rate of calling queries and mutations.
yarn add @envelop/rate-limiter
import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine } from '@envelop/core'
import { IdentifyFn, useRateLimiter } from '@envelop/rate-limiter'
const identifyFn: IdentifyFn = context => {
return context.request.ip
}
const getEnveloped = envelop({
plugins: [
useEngine({ parse, validate, specifiedRules, execute, subscribe }),
// ... other plugins ...
useRateLimiter({
identifyFn
})
]
})
By default, we assume that you have the GraphQL directive definition as part of your GraphQL schema (
directive @rateLimit(max: Int, window: String, message: String) on FIELD_DEFINITION
).
Then, in your GraphQL schema SDL, you can add @rateLimit
directive to your fields, and the limiter
will get called only while resolving that specific field:
type Query {
posts: [Post]! @rateLimit(
window: "5s", // time interval window for request limit quota
max: 10, // maximum requests allowed in time window
message: "Too many calls!" // quota reached error message
)
# unlimitedField: String
}
You can apply that directive to any GraphQL
field
definition, not only to root fields.
The message
argument of the @rateLimit
directive can be dynamic. You {{var}}
or {{ var }}
syntax to interpolate variables.
type Query {
posts: [Post]! @rateLimit(window: "5s", max: 10, message: "Too many calls made by {{ id }}")
}
The only available variable so far is
id
.
All options available to the graphql-rate-limit getGraphQLRateLimiter function may also be passed into useRateLimiter.
You can find more details here: https://github.com/teamplanes/graphql-rate-limit#readme
FAQs
This plugins uses [`graphql-rate-limit`](https://github.com/teamplanes/graphql-rate-limit#readme) in order to limit the rate of calling queries and mutations.
The npm package @envelop/rate-limiter receives a total of 9,143 weekly downloads. As such, @envelop/rate-limiter popularity was classified as popular.
We found that @envelop/rate-limiter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.