Usama0121/ariadne-jwt

KeyError: 'ariadne_jwt'

Chuks1993 opened this issue · 1 comments

Thanks for creating this package!

Please bare with me as I am new to python and Django especially but I have this issue that sometimes when I runserver I get this error:

Exception in thread django-main-thread: Traceback (most recent call last): File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 973, in _bootstrap_inner self.run() File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run self.check(display_num_errors=True) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check all_issues = checks.run_checks( File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 125, in check_dependencies if not _contains_subclass('django.contrib.messages.middleware.MessageMiddleware', settings.MIDDLEWARE): File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/contrib/admin/checks.py", line 41, in _contains_subclass candidate_cls = import_string(path) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 850, in exec_module File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed File "/Users/chuksgrinage/.pyenv/versions/3.9.6/lib/python3.9/site-packages/ariadne_jwt/middleware.py", line 6, in <module> from .utils import get_authorization_header File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 989, in _find_and_load_unlocked KeyError: 'ariadne_jwt'

I cant figure this out and I've searched all over for a solution but nothing helped. My last resort was to reach out to the creator directly. Any help would me greatly appreciated.

This is where I'm getting the error. It seems to happen anywhere I am utilizing the decorators:

`from ariadne import convert_kwargs_to_snake_case

from ariadne_jwt.decorators import login_required, token_auth
from graphql import GraphQLError

from account.models import User

@convert_kwargs_to_snake_case
@token_auth
def resolve_token_auth(obj, info, **kwargs):
"""Gets current current user from context and returns a user, token and refresh token"""
print(info.context)
user = info.context.get("request").user
return {"user": user}

@convert_kwargs_to_snake_case
def resolve_signup_user(obj, info, input):
"""Takes an input dict consisting of email, username and password to sign up a new user then returns the user"""
if User.objects.filter(email=input["email"]).exists():
raise GraphQLError("This email already exists please try another email")
if User.objects.filter(username=input["username"]).exists():
raise GraphQLError("This username already exists please try another email")
user = User.objects.create_user(**input)
user.save()
return user
`