https://github.com/turfapp/absinthe_rate_limiting
Middleware-based rate limiting for Absinthe
https://github.com/turfapp/absinthe_rate_limiting
absinthe absinthe-graphql elixir
Last synced: 4 months ago
JSON representation
Middleware-based rate limiting for Absinthe
- Host: GitHub
- URL: https://github.com/turfapp/absinthe_rate_limiting
- Owner: turfapp
- License: mit
- Created: 2025-02-02T20:44:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-03T20:49:47.000Z (over 1 year ago)
- Last Synced: 2025-10-22T08:25:35.446Z (8 months ago)
- Topics: absinthe, absinthe-graphql, elixir
- Language: Elixir
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# AbsintheRateLimiting
[](https://hex.pm/packages/absinthe_rate_limiting)
`absinthe_rate_limiting` is a middleware-based rate limiter for
[Absinthe](https://hexdocs.pm/absinthe/overview.html) that uses
[Hammer](https://hexdocs.pm/hammer/index.html).
## Installation
`absinthe_rate_limiting` is [available in
Hex](https://hexdocs.pm/absinthe_rate_limiting), and can be installed by adding
`:absinthe_rate_limiting` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:absinthe_rate_limiting, "~> 0.1.0"}
]
end
```
## Basic usage
To use the rate limiting middleware, you must first configure Hammer. For example:
```elixir
config :hammer,
backend:
{Hammer.Backend.ETS, [
expiry_ms: 1000 * 60 * 60 * 4,
cleanup_interval_ms: 1000 * 60 * 10
]}
```
See the [Hammer documentation](https://hexdocs.pm/hammer) for more information.
The next step is to add the middleware to the query that needs to be rate
limited:
```elixir
field :my_field, :string do
middleware AbsintheRateLimiting.RateLimit
resolve &MyApp.Resolvers.my_field/3
end
```
For the full usage information, see `AbsintheRateLimiting.RateLimit`.