graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.3k stars 768 forks source link

res.set_cookie('auth-token', token) #1433

Closed amraaone closed 1 year ago

amraaone commented 1 year ago

Is your feature request related to a problem? Please describe. Hello everyone, I am freshman Django with Graphene-django package. How to LoginMutation getting token to save response? and customMiddleware jwt.verify that token. Last two day I tried. But failed. HELP. Is Graphene can save to request, response in data? create custom context?

Describe the solution you'd like Graphene.as_view(schema=schema, graphiql=True)(request, user=request.user, token=request.token) or class CustomGraphQLView(LoginRequiredMixin, GraphQLView): def get_context(self, request):

Get the default context from the parent class

    context = super().get_context(request)
    # Add custom user context
    context["user_custom_data"] = "Custom user data"
    return context

above code suggest from chatgpt. but not works. I don't know how to save Logged in User token in request, and all of mutations and users gets a info.context.user gets and process it.

erikwrede commented 1 year ago

Hey there, the issues in this repository are only for the main Graphene library. I'm moving this issue to the appropriate repository 🙂

sjdemartini commented 1 year ago

I'm not sure I understand the issue exactly and what doesn't work, but I'd recommend checking out https://django-graphql-jwt.domake.io/, since it sounds like you want to incorporate JWT authentication with django-graphene.

If you still encounter some bug that seems to be specific to graphene-django, please provide more detailed/thorough code samples (and with code formatting per Markdown specs), with specific notes about what does not work/where. For instance a traceback and error message. This type of question is probably better suited for Stack Overflow than a GitHub issue.

Closing this out for now.