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 timeout and version parameters and passed down.
Cache key must be either str or callable. Callable will receive same argument as resolver then return cache key.
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
Hashes for ariadne_django_ext-1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bf814930c54b312fa1cfde4d83c5c0e7845351264edc52753a5b7d9553cb630 |
|
MD5 | 13459ef330bf07e6fa952e2827812cd0 |
|
BLAKE2b-256 | 2fbc08d6d5cb40498e82ef94d02623495fd814481e7f6c833af37ccad1f32409 |