Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Update django-graphql-jwt==0.1.5 version recommended in the tutorial #10

Open
BonfaceKilz opened this issue May 20, 2019 · 2 comments

Comments

@BonfaceKilz
Copy link

In the tutorial, when creating the venv, the recommended version of django-graphql-jwt is 0.1.5. This throws some errors when following along with the Authentication bit of the tutorial. From the changelog, the graphene middleware was introduced in v0.2.0.

@satwikk
Copy link

satwikk commented Aug 5, 2019

@BonfaceKilz Thanks for reporting the issue, and mentioning about the changelog. Upgrading django-graphql-jwt to v0.2.0, resolved the issue.

pip install django-graphql-jwt==0.2.0

@ksajjan
Copy link

ksajjan commented Jun 8, 2021

While following the tutorial, I also installed django-graphql-jwt-0.1.5 (as it is mentioned).

In the autentication part, I started getting the middleware errors.

Internal Server Error: /graphql/                                                                                                                      
Traceback (most recent call last):                                                                                                                    
  File "/home/hackernews/venv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 34, in inner                 
    response = get_response(request)                                                                                                                  
  File "/home/hackernews/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 126, in _get_response             
    response = self.process_exception_by_middleware(e, request)                                                                                       
  File "/home/hackernews/venv/lib/python3.8/site-packages/django/core/handlers/base.py", line 124, in _get_response             
    response = wrapped_callback(request, *callback_args, **callback_kwargs)                                                                           
  File "/home/hackernews/venv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view            
    return view_func(*args, **kwargs)                                                                                                                 
  File "/home/hackernews/venv/lib/python3.8/site-packages/django/views/generic/base.py", line 62, in view                       
    self = cls(**initkwargs)                                                                                                                          
  File "/home/hackernews/venv/lib/python3.8/site-packages/graphene_django/views.py", line 88, in __init__                       
    self.middleware = list(instantiate_middleware(middleware))                                                                                        
  File "/home/hackernews/venv/lib/python3.8/site-packages/graphene_django/views.py", line 48, in instantiate_middleware         
    yield middleware()                                                                                                                                
TypeError: __init__() missing 1 required positional argument: 'get_response'     

Tried to figure it out and answer suggested "it could be due to different settings variable for middleware in different django versions (MIDDLEWARE and MIDDLEWARE_CLASSES)". Made an update in graphe settings (from MIDDLEWARE TO MIDDLEWARE_CLASSES) and it worked. (haven't checked other impact)

GRAPHENE = {
    'SCHEMA': 'hackernews.schema.schema',
    'MIDDLEWARE': [
        'graphql_jwt.middleware.JSONWebTokenMiddleware',
    ]
}

However after checking this issue, I upgraded to pip install django-graphql-jwt==0.2.0 and everything works fine.

Please make an update in tutorial.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants