Skip to content
Django registration and authentication with GraphQL.
Python Other
  1. Python 98.9%
  2. Other 1.1%
Branch: master
Clone or download
Latest commit 3bcea54 Feb 21, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Update documentation files Feb 21, 2020
graphql_auth Bump version Feb 21, 2020
quickstart Bump django from 3.0.2 to 3.0.3 in /quickstart Feb 11, 2020
testproject run black Feb 6, 2020
tests add pk to UserNode Feb 9, 2020
.coveragerc first commit Jan 15, 2020
.gitignore update gitignore Jan 23, 2020
.readthedocs.yml add readthedocs Jan 27, 2020
.travis.yml add black + contributing file Feb 6, 2020
CHANGES.md Update documentation files Feb 21, 2020
CONTRIBUTING.md
CONTRIBUTORS.md Update documentation files Feb 21, 2020
LICENSE
MANIFEST.in first commit Jan 15, 2020
Makefile add black + contributing file Feb 6, 2020
README.md update readme Feb 8, 2020
README.rst update readme Jan 28, 2020
demo.gif update readme Feb 8, 2020
make_migrations.py add migration helper scripts Jan 22, 2020
migrations_settings.py add migration helper scripts Jan 22, 2020
mkdocs.yml add black + contributing file Feb 6, 2020
setup.cfg
setup.py add black + contributing file Feb 6, 2020
tox.ini add black + contributing file Feb 6, 2020

README.md

Django GraphQL Auth

Django registration and authentication with GraphQL.

Codecov Coverage Build Status Pypi Documentation Status contributions welcome

Demo

Demo Video

About

Abstract all the basic logic of handling user accounts out of your app, so you don't need to think about it and can get up and running faster.

No lock-in. When you are ready to implement your own code or this package is not up to your expectations , it's easy to extend or switch to your implementation.

Documentation

Documentation is available at read the docs.

Features

  • Awesome docs 🎉
  • Fully compatible with Relay
  • Works with default or custom user model
  • JWT authentication (with Django GraphQL JWT)
  • User query with filters (with Django Filter and Graphene Django)
  • User registration with email verification
  • Add secondary email, with email verification too
  • Resend activation email
  • Retrieve/Update user
  • Archive user
  • Permanently delete user or make it inactive
  • Turn archived user active again on login
  • Track user status (archived, verified, secondary email)
  • Password change
  • Password reset through email
  • Revoke user refresh tokens on account archive/delete/password change/reset
  • All mutations return success and errors
  • Default email templates (you will customize though)
  • Customizable, no lock-in

Full Schema

import graphene

from graphql_auth.schema import UserQuery
from graphql_auth import mutations

class AuthMutation(graphene.ObjectType):
    register = mutations.Register.Field()
    verify_account = mutations.VerifyAccount.Field()
    resend_activation_email = mutations.ResendActivationEmail.Field()
    send_password_reset_email = mutations.SendPasswordResetEmail.Field()
    password_reset = mutations.PasswordReset.Field()
    password_change = mutations.PasswordChange.Field()
    update_account = mutations.UpdateAccount.Field()
    archive_account = mutations.ArchiveAccount.Field()
    delete_account = mutations.DeleteAccount.Field()
    send_secondary_email_activation =  mutations.SendSecondaryEmailActivation.Field()
    verify_secondary_email = mutations.VerifySecondaryEmail.Field()
    swap_emails = mutations.SwapEmails.Field()
    remove_secondary_email = mutations.RemoveSecondaryEmail.Field()

    # django-graphql-jwt inheritances
    token_auth = mutations.ObtainJSONWebToken.Field()
    verify_token = mutations.VerifyToken.Field()
    refresh_token = mutations.RefreshToken.Field()
    revoke_token = mutations.RevokeToken.Field()


class Query(UserQuery, graphene.ObjectType):
    pass


class Mutation(AuthMutation, graphene.ObjectType):
    pass


schema = graphene.Schema(query=Query, mutation=Mutation)

Relay

Import mutations from the relay module:

from graphql_auth import relay

class AuthMutation(graphene.ObjectType):
   register = relay.Register.Field()
   # ...

Example

Handling user accounts becomes super easy.

mutation {
  register(
    email: "new_user@email.com",
    username: "new_user",
    password1: "123456super",
    password2: "123456super",
  ) {
    success,
    errors,
    token,
    refreshToken
  }
}

Check the status of the new user:

u = UserModel.objects.last()
u.status.verified
# False

During the registration, an email with a verification link was sent.

mutation {
  verifyAccount(
    token:"<TOKEN ON EMAIL LINK>",
  ) {
    success,
    errors
  }
}

Now user is verified.

u.status.verified
# True

Check the installation guide or jump to the quickstart. Or if you prefer, browse the api.

Contributing

See CONTRIBUTING.md

You can’t perform that action at this time.