graphql-python icon indicating copy to clipboard operation
graphql-python copied to clipboard

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

Open BonfaceKilz opened this issue 6 years ago • 2 comments
trafficstars

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.

BonfaceKilz avatar May 20 '19 19:05 BonfaceKilz

@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

satwikk avatar Aug 05 '19 16:08 satwikk

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.

ksajjan avatar Jun 08 '21 12:06 ksajjan