Implementation Example?
See original GitHub issueHello! It’s great to have this, I’m just a little confused on implementation. I’ve added the authentication backends settings, the middleware settings, and the verify/refresh token mutations added.
This is probably obvious, but how do I create a login mutation? This is what I have from the howtographql tutorial:
from django.contrib.auth.models import User
from django.contrib.auth import authenticate
from graphene import relay
from graphene_django import DjangoObjectType
class UserNode(DjangoObjectType):
class Meta:
model = User
filter_fields = [
'username',
]
interfaces = (relay.Node, )
class LogIn(graphene.Mutation):
user = graphene.Field(UserNode)
class Arguments:
username = graphene.String()
password = graphene.String()
def mutate(self, info, username, password):
user = authenticate(
username=username,
password=password,
)
if not user:
raise Exception('Invalid username or password')
info.context.session['token'] = user.token
return LogIn(user=user)
class Mutation(object):
login = LogIn.Field()
Of course that’s looking for the token property for a user, which is not found. Any thoughts? Forgive my newness to django/graphql!
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
What is an implementation plan? 6 steps to create one
An implementation plan is a document that outlines the steps your team should take to accomplish a shared goal or initiative. Implementation ...
Read more >What is Implementation?
Implementation can mean different things in different industries where goals and supporting actions vary. The following are some examples: Computer science and ...
Read more >Example Implementation Plan - How to ...
Example Implementation Plan - How to Implement Business Strategy · 1. Mission, Vision and Values · 2. Strategic Plan · 3. Organizational Goals...
Read more >Strategic Implementation: Definition, Plan, Process Examples
Strategic implementation is a process of turning plans into action using a specified strategy. · The five steps of the strategic implementation process...
Read more >What is an Implementation Plan & How Do I Create One? ...
Here's a simple implementation plan example we've created using ProjectManager to help you better understand how implementation plans work.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @evanheckert!
welcome to GraphQL.
you can use a
resolver
method for the token and others non-model fields: http://docs.graphene-python.org/en/latest/types/objecttypes/#resolversAdd Django
login
function to your mutation to attach authenticated user to the current session: https://docs.djangoproject.com/en/1.11/topics/auth/default/#how-to-log-a-user-in@TitanFighter https://github.com/howtographql/graphql-python