I've implemented jwt authentication in django using Django-graphql-jwt library, now I want to allow get/post on my endpoint (/graphql) only for requests with JWT token. There are examples in django-graphql-jwt documentation like @login_required, but I don't want to put a decorator above every query and mutation. So, I've decided to restrict an access to a view. I added path('graphql/', PrivateGraphQLView.as_view()) in url.py but how can I implement request checking for a valid token in the header?
from graphene_django.views import GraphQLView
class PrivateGraphQLView(GraphQLView):
pass
Find my answer here JWT Authentication: Use UI token to authenticate Graphene/Django (GraphQL) queries? But actually I've decided not to go deep down as it's just a simple app, and I need at least one mutation (get a token) open, so decorators from django-graphql-jwt should be enough