Usable utility extensions for Ariadne & Django
Project description
ariadne-django-ext
Installation • Contributing • License
Custom, simple Django User model with email as username
Installation
pip install ariadne-django-ext
Usage
cache
cache decorator will cache a result returned from resolver using Django cache framework. You can it accepts same keyword arguments and passed down to Django cache.
Cache key must be either value or callable. Callable will receive same arguments as resolver then return cache key. Callable may return None to bypass the cache.
It uses typename and key from info.path as cache key prefix.
from ariadne_django_ext import cache
@cache(key='cache_key')
def resolver(parent, info):
...
return 'result'
wrap_result
wrap_result decorator wraps return value of a resolver into dictionary with the key
from ariadne_django_ext import wrap_result
@wrap_result(key='result')
def resolver(parent, info):
return 'result'
Above example will return following dict
{ "result": "result" }
isAuthenticated & isStaff directive
A resolver will receive an authenticated user as keyword argument.
directive @isAuthenticated on FIELD_DEFINITION
type User {
id: ID
username: String
ipAddress: String @isAuthenticated
}
from ariadne_django_ext import IsAuthenticatedDirective
schema = make_executable_schema(
type_defs,
resolvers,
directives={"isAuthenticated": IsAuthenticatedDirective}
)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ariadne-django-ext-1.6.tar.gz
.
File metadata
- Download URL: ariadne-django-ext-1.6.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69bcd32493e281ff47d568b0991052c7b88c7636582b700975703fdfdd28c040 |
|
MD5 | ad55e3c4f3efb534178d201338998d8e |
|
BLAKE2b-256 | d1b0a89d1f40d9c669cb6242c29d673d7cb83e16ce17b704ab4bba4b257dee92 |
File details
Details for the file ariadne_django_ext-1.6-py3-none-any.whl
.
File metadata
- Download URL: ariadne_django_ext-1.6-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.9.7 Linux/5.8.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf87ab46512f7b52f1cd95a4278d04e46462334b033783d033b223c9de48a962 |
|
MD5 | caa4831fc72967a6221e055d9ce70548 |
|
BLAKE2b-256 | 70aed31af24fd6227c8d90c20d9bc3106643bec10276e6686215ec9d648e08e5 |