# 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']
```
Raw data
{
"_id": null,
"home_page": "https://github.com/abelayalew/graphi",
"name": "graphi_crud",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.11",
"maintainer_email": null,
"keywords": null,
"author": "abelayalew",
"author_email": "abelayalew81@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/43/a3/7ee01f047f5d0ea8063f627afb263eeef61a02515e852cd3743d4584c56c/graphi_crud-1.2.3.3.tar.gz",
"platform": null,
"description": "# Django Graphene CRUD Generator\n\n## Installation\n```\npip install graphi-crud\n```\n\n## Usage\n\n```\nimport graphene\nfrom graphi_crud.queries import Queries\nfrom graphi_crud.create_mutation import CreateMutation\nfrom graphi_crud.update_mutation import UpdateMutation\nfrom graphi_crud.delete_mutation import DeleteMutation\n\n\nQueries.generate_queries([\"accounts\"])\nCreateMutation.generate_mutations(['accounts'])\nUpdateMutation.generate_mutations(['accounts'])\nDeleteMutation.generate_mutations(['accounts'])\n\nclass Query(Queries):\n pass\n\nclass Mutation(CreateMutation, UpdateMutation, DeleteMutation):\n pass\n\n\nschema = graphene.Schema(query=Query, mutation=Mutation)\n\n```\n\nregister your `schema` in settings and your good to go\n\n## writing Queries\n\n```\n{\n user(where: {email: {icontains: \"user\"}}, offset: 10, limit: 10){\n id\n email\n }\n}\n```\n\n## create mutation example\n\n```\nmutation{\n createUser(inputs: {email: \"user@gmail.com\", username: \"newuser\"}){\n data{\n id\n email\n }\n }\n}\n```\n\n## update mutation example\n\n```\nmutation{\n updateUser(inputs: {lastLogin: \"2023-12-12\"}, where: {email: {icontains: \"someuser\"}}){\n affectedRows\n data {\n id\n username\n }\n }\n}\n```\n\n## delete mutation examples\n\n```\nmutation{\n deleteUser(where: {email: {icontains: \"someuser\"}}){\n affectedRows\n }\n}\n```\n\n## permissions\nadd `graphql_permissions` attribute on your model class with a list of permissions\nexample:\n``` \n class Employee(models.Model):\n ...fields...\n graphql_permissions = ['accounts.add_employee', 'accounts.change_employee']\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Graphene Dajngo CRUD generator",
"version": "1.2.3.3",
"project_urls": {
"Homepage": "https://github.com/abelayalew/graphi",
"Repository": "https://github.com/abelayalew/graphi"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2f81375769d938bb423fc6eee3e4b2ebad9bbc2647cc37a181e22131aa410d4a",
"md5": "2660df241f63631454ebf8b2541d2028",
"sha256": "6a88f71409ba5cfb90ac89e72f184212a6ffec766a4a18a35f71c47a8f10d012"
},
"downloads": -1,
"filename": "graphi_crud-1.2.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2660df241f63631454ebf8b2541d2028",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.11",
"size": 9886,
"upload_time": "2024-07-30T08:22:11",
"upload_time_iso_8601": "2024-07-30T08:22:11.541076Z",
"url": "https://files.pythonhosted.org/packages/2f/81/375769d938bb423fc6eee3e4b2ebad9bbc2647cc37a181e22131aa410d4a/graphi_crud-1.2.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "43a37ee01f047f5d0ea8063f627afb263eeef61a02515e852cd3743d4584c56c",
"md5": "c0f72e76d454787ef6c8b1de16880500",
"sha256": "e31138ab2a0b4c5cfb2f26aed9d420dcdc6c3959f3e19ef3ae63fe8621fd68b3"
},
"downloads": -1,
"filename": "graphi_crud-1.2.3.3.tar.gz",
"has_sig": false,
"md5_digest": "c0f72e76d454787ef6c8b1de16880500",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.11",
"size": 7039,
"upload_time": "2024-07-30T08:22:13",
"upload_time_iso_8601": "2024-07-30T08:22:13.311430Z",
"url": "https://files.pythonhosted.org/packages/43/a3/7ee01f047f5d0ea8063f627afb263eeef61a02515e852cd3743d4584c56c/graphi_crud-1.2.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-30 08:22:13",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "abelayalew",
"github_project": "graphi",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "black",
"specs": [
[
"==",
"23.3.0"
]
]
},
{
"name": "Django",
"specs": [
[
"==",
"5.0"
]
]
},
{
"name": "django-filter",
"specs": [
[
"==",
"23.5"
]
]
},
{
"name": "graphene-django",
"specs": [
[
"==",
"3.2.0"
]
]
},
{
"name": "ipython",
"specs": [
[
"==",
"8.14.0"
]
]
},
{
"name": "pre-commit",
"specs": [
[
"==",
"3.3.3"
]
]
},
{
"name": "prospector",
"specs": [
[
"==",
"1.10.2"
]
]
},
{
"name": "python-decouple",
"specs": [
[
"==",
"3.7"
]
]
},
{
"name": "django-cors-headers",
"specs": [
[
"==",
"4.3.1"
]
]
}
],
"lcname": "graphi_crud"
}