Installation • Contributing • License
Custom, simple Django User model with email as username
pip install ariadne-django-ext
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 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" }
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}
)
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.