Skip to main content

Graphene Dajngo CRUD generator

Project description

Django Graphene CRUD Generator

Installation

pip install graphi-crud

Usage

import graphene
from graphi_crud.queries import Queries
from graphi_crud.create_mutation import CreateMutation
from graphi_crud.update_mutation import UpdateMutation
from graphi_crud.delete_mutation import DeleteMutation


Queries.generate_queries(["accounts"])
CreateMutation.generate_mutations(['accounts'])
UpdateMutation.generate_mutations(['accounts'])
DeleteMutation.generate_mutations(['accounts'])

class Query(Queries):
    pass

class Mutation(CreateMutation, UpdateMutation, DeleteMutation):
    pass


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

register your schema in settings and your good to go

writing Queries

{
  user(where: {email: {icontains: "user"}}, offset: 10, limit: 10){
    id
    email
  }
}

create mutation example

mutation{
  createUser(inputs: {email: "user@gmail.com", username: "newuser"}){
    data{
      id
      email
    }
  }
}

update mutation example

mutation{
  updateUser(inputs: {lastLogin: "2023-12-12"}, where: {email: {icontains: "someuser"}}){
    affectedRows
    data {
      id
      username
    }
  }
}

delete mutation examples

mutation{
  deleteUser(where: {email: {icontains: "someuser"}}){
    affectedRows
  }
}

permissions

add graphql_permissions attribute on your model class with a list of permissions example:

  class Employee(models.Model):
      ...fields...
      graphql_permissions = ['accounts.add_employee', 'accounts.change_employee']

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graphi_crud-1.2.3.3.tar.gz (7.0 kB view details)

Uploaded Source

Built Distribution

graphi_crud-1.2.3.3-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file graphi_crud-1.2.3.3.tar.gz.

File metadata

  • Download URL: graphi_crud-1.2.3.3.tar.gz
  • Upload date:
  • Size: 7.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.9.9-1-MANJARO

File hashes

Hashes for graphi_crud-1.2.3.3.tar.gz
Algorithm Hash digest
SHA256 e31138ab2a0b4c5cfb2f26aed9d420dcdc6c3959f3e19ef3ae63fe8621fd68b3
MD5 c0f72e76d454787ef6c8b1de16880500
BLAKE2b-256 43a37ee01f047f5d0ea8063f627afb263eeef61a02515e852cd3743d4584c56c

See more details on using hashes here.

File details

Details for the file graphi_crud-1.2.3.3-py3-none-any.whl.

File metadata

  • Download URL: graphi_crud-1.2.3.3-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.9.9-1-MANJARO

File hashes

Hashes for graphi_crud-1.2.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6a88f71409ba5cfb90ac89e72f184212a6ffec766a4a18a35f71c47a8f10d012
MD5 2660df241f63631454ebf8b2541d2028
BLAKE2b-256 2f81375769d938bb423fc6eee3e4b2ebad9bbc2647cc37a181e22131aa410d4a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page