Rate Limit
You can use @graphql-mesh/plugin-rate-limit
plugin in order to limit the rate of calling queries
and mutations.
Getting Started
npm i @graphql-mesh/plugin-rate-limit
Example Configuration
.meshrc.yaml
# ...
plugins:
- rateLimit:
config:
# Add as many rules as you want
- type: Query
field: foo
max: 5 # requests limit for a time period
ttl: 5000 # time period
identifier: '{context.userId}'
Config API Reference
config
(type:Array of Object
, required):type
(type:String
, required) - The type name that the following field belongs tofield
(type:String
, required) - The field of the type that the rate limit is applied tomax
(type:Int
, required) - The maximum number of requests that can be made in a given time periodttl
(type:Int
, required) - The time period in which the rate limit is appliedidentifier
(type:String
, required) - The identifier expression that determines the identity of the request (e.g.{context.req.socket.remoteAddress}
)