Index

Graphene

  1. Queries
  2. migrations
  3. UserModel
  4. User Schema
  5. cors
  6. static
  7. headers
  8. payumoney
  9. imageupload
  10. Total count

User Schema

users/schema.py
from 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()


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)



mutation {
    createUser(name: "Probiquery", email: "probiquery@gmail.com", password: "@tulan123") {
        user {
            id
            name
            email
        }
    }
}