django-graphql-auth is an awesome package, but the documentation doesn't say much about models association to a custom user model.
I am looking for a away to make use of this package with a custom Register Mutation for both user types Applicant and Employer
class User(AbstractUser):
email = models.EmailField(blank=False,
max_length=255,
verbose_name="email address")
is_applicant = models.BooleanField(default=False)
is_employer = models.BooleanField(default=False)
USERNAME_FIELD = "username"
EMAIL_FIELD = "email"
class Applicant(models.Model):
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
primary_key=True,
)
fullname = models.CharField(max_length=255, null=True)
class Employer(models.Model):
user = models.OneToOneField(
User,
on_delete=models.CASCADE,
primary_key=True,
)
company_name = models.CharField(max_length=225, null=True)
Mutation goal to achieve:
mutation {
registerApplicant(
input: {
email: "new_applicant@email.com",
username: "new_applicant",
password1: "createsuperpassword",
password2: "createsuperpassword",
isApplicant: true,
applicant {
fullname: "New Applicant"
}
}
) {
success,
errors,
token,
refreshToken
}
}
mutation {
registerEmployer(
input: {
email: "new_employer@email.com",
username: "new_employer",
password1: "createsuperpassword",
password2: "createsuperpassword",
isEmployer: true,
employer {
fullname: "New Employer"
}
}
) {
success,
errors,
token,
refreshToken
}
}