Strawberry GraphQL Ratelimit Extension
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file strawberry-ratelimit-1.0.1.tar.gz
.
File metadata
- Download URL: strawberry-ratelimit-1.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f54dd6ac032aa94af4557ac5deab2e3a245bf81d71a7a2d0c8faa458672dbff2 |
|
MD5 | 025f41aa34301dbf6bd5c294cd46fc96 |
|
BLAKE2b-256 | 0fe6482f33831499065a46f8f325c96729488d75bff8d536e21a2df300d23697 |