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
Release history Release notifications | RSS feed
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.1.6.tar.gz
(6.6 kB
view hashes)
Built Distribution
Close
Hashes for graphi_crud-1.1.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38a92d7f1f7a964e988987b34efc43f7027c8207f170ba2e7821f16d3f994781 |
|
MD5 | 26e08bb001c90b378da182701a7c51b9 |
|
BLAKE2b-256 | 15e75ddb890080ce9fb0d8ce425f0205354b4eb180bf860ff5449aaebf5f225f |