Strawberry GraphQL Ratelimit Extension
Installation
pip3 install strawberry-ratelimit
Usage
my_schema = strawberry.Schema(
query=Query,
mutation=Mutation,
extensions=[
# 60req/min
ExtensionRatelimit(
type_name=['getUser', 'updateUser', 'user_friends'], # queries, mutations, internal funcs.
rate_max=60,
rate_seconds=60,
depth_max=50, # Maximum depth of the query
call_max=500 # Maximum call count
)
]
)
Limitations
-
Consider this project as a reference code. Do not use it for production.
- Currently, the code uses a single global dict variable to store users' query/mutation accesses.
- Although there is a code to flush the list of user's IP after a certain amount of logs, the code itself does not collect garbage and it may consume a lot of memory depending on the number of users.
- It is recommended to re-write this code with DB support for optimization.
Metadata
Release files for strawberry-ratelimit 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| strawberry-ratelimit-1.0.1.tar.gz | 6.1 kB | Details |
Release files / strawberry-ratelimit-1.0.1.tar.gz
| Download URL | strawberry-ratelimit-1.0.1.tar.gz |
|---|---|
| Size | 6.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f54dd6ac032aa94af4557ac5deab2e3a245bf81d71a7a2d0c8faa458672dbff2
|
|
BLAKE2b-256 checksum How to use checksums |
0fe6482f33831499065a46f8f325c96729488d75bff8d536e21a2df300d23697
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.8.1 requests/2.24.0 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/2.7.18
|