Skip to main content

CircleCI PyPI version

Eaiser to use django-ratelimit for graphql in django.

Install

pip install django-graphql-ratelimit

Usage

ratelimit key support gql:xxx, where xxx is argument.

from django_graphql_ratelimit import ratelimit

class RequestSMSCode(graphene.Mutation):
    class Arguments:
        phone = graphene.String(required=True)

    ok = graphene.Boolean()

    @ratelimit(key="ip", rate="10/m", block=True)
    @ratelimit(key="gql:phone", rate="5/m", block=True)
    def mutate(self, info, phone):
        request = info.context
        # send sms code logic
        return RequestSMSCode(ok=True)

You can use django-ratelimit keys except get:xxx and post:xxx:

  • ip - Use the request IP address (i.e. request.META['REMOTE_ADDR']) I suggest you to use django-ipware to get client ip, modify your MIDDLEWARE in settings:
MIDDLEWARE = [
"django_graphql_ratelimit.middleware.ParseClientIpMiddleware",
...
]
  • header:x-x - Use the value of request.META.get('HTTP_X_X', '').
  • user - Use an appropriate value from request.user. Do not use with unauthenticated users.
  • user_or_ip - Use an appropriate value from request.user if the user is authenticated, otherwise use request.META['REMOTE_ADDR'].

Metadata

Release files for django-graphql-ratelimit 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-graphql-ratelimit 1.0.2
File Size Uploaded Provenance
django-graphql-ratelimit-1.0.2.tar.gz 5.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-graphql-ratelimit 1.0.2
File Interpreter ABI Platform
django_graphql_ratelimit-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.6 kB

Release files / django-graphql-ratelimit-1.0.2.tar.gz

Download URL django-graphql-ratelimit-1.0.2.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b95d6322301feb7e067fdd4d62b104a0294e2c09ab45c113eb0c1503565413ae
BLAKE2b-256 checksum
How to use checksums
8dcf8210f4593c2d44ced69b20699337dfde2d0655e820591cbd3efbd9530701
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / django_graphql_ratelimit-1.0.2-py3-none-any.whl

Download URL django_graphql_ratelimit-1.0.2-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b6a9a6517b97e1126dbf01ba318b22ee4ab14d304e8211d10ddf105e4a72917
BLAKE2b-256 checksum
How to use checksums
e75d1ff5624c25e99e3fe08f5b507abb57f759597bdd9c758061a0ea4cac3325
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Security for django-graphql-ratelimit 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page