Index
User Schema
users/schema.pyfrom django.contrib.auth import get_user_model
import graphene
from graphene_django import DjangoObjectType
class UserType(DjangoObjectType):
class Meta:
model = get_user_model()
class CreateUser(graphene.Mutation):
user = graphene.Field(UserType)
class Arguments:
name = graphene.String(required=True)
password = graphene.String(required=True)
email = graphene.String(required=True)
def mutate(self, info, name, password, email):
user = get_user_model()(
name=name,
email=email,
)
user.set_password(password)
user.save()
return CreateUser(user=user)
class Mutation(graphene.ObjectType):
create_user = CreateUser.Field()
import graphene
from graphene_django import DjangoObjectType
class UserType(DjangoObjectType):
class Meta:
model = get_user_model()
class CreateUser(graphene.Mutation):
user = graphene.Field(UserType)
class Arguments:
name = graphene.String(required=True)
password = graphene.String(required=True)
email = graphene.String(required=True)
def mutate(self, info, name, password, email):
user = get_user_model()(
name=name,
email=email,
)
user.set_password(password)
user.save()
return CreateUser(user=user)
class Mutation(graphene.ObjectType):
create_user = CreateUser.Field()
sakhura_backend/schema.py
import graphene
import jewellery.schema
import users.schema
class Query(jewellery.schema.Query, graphene.ObjectType):
pass
class Mutation(users.schema.Mutation, jewellery.schema.CategoryMutation, jewellery.schema.ProductMutation):
pass
schema = graphene.Schema(query=Query, mutation=Mutation)
import jewellery.schema
import users.schema
class Query(jewellery.schema.Query, graphene.ObjectType):
pass
class Mutation(users.schema.Mutation, jewellery.schema.CategoryMutation, jewellery.schema.ProductMutation):
pass
schema = graphene.Schema(query=Query, mutation=Mutation)
mutation {
createUser(name: "Probiquery", email: "probiquery@gmail.com", password: "@tulan123") {
user {
id
name
email
}
}
}
createUser(name: "Probiquery", email: "probiquery@gmail.com", password: "@tulan123") {
user {
id
name
}
}
}