graphi_crud


Namegraphi_crud JSON
Version 1.1.9 PyPI version JSON
download
home_pagehttps://github.com/abelayalew/graphi
SummaryGraphene Dajngo CRUD generator
upload_time2024-03-14 06:44:14
maintainer
docs_urlNone
authorabelayalew
requires_python>=3.11,<4.0
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "abelayalew",
    "author_email": "abelayalew81@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/17/2f/a479c5e38ce50b6d6537d5488795466419ae9cc141ea262cd85e4f724424/graphi_crud-1.1.9.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.1.9",
    "project_urls": {
        "Homepage": "https://github.com/abelayalew/graphi",
        "Repository": "https://github.com/abelayalew/graphi"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cfd754da92441c0269ea3cf71b6a21eebce26c8457ff297f01bd2b3ded3ad701",
                "md5": "36cb86de460ce8114b7ad4db3503c74d",
                "sha256": "a390f414c3fffffeceaef6b2863ae50e6ebd940e5ce124454df6300dc6a69a9e"
            },
            "downloads": -1,
            "filename": "graphi_crud-1.1.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "36cb86de460ce8114b7ad4db3503c74d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 9486,
            "upload_time": "2024-03-14T06:44:12",
            "upload_time_iso_8601": "2024-03-14T06:44:12.214736Z",
            "url": "https://files.pythonhosted.org/packages/cf/d7/54da92441c0269ea3cf71b6a21eebce26c8457ff297f01bd2b3ded3ad701/graphi_crud-1.1.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "172fa479c5e38ce50b6d6537d5488795466419ae9cc141ea262cd85e4f724424",
                "md5": "ebee1f73ac0ecdaeba8b09053c2a9572",
                "sha256": "719657f47b3e6524b821a77faa795510fc02db9a5c08513c931c394c6fd0679c"
            },
            "downloads": -1,
            "filename": "graphi_crud-1.1.9.tar.gz",
            "has_sig": false,
            "md5_digest": "ebee1f73ac0ecdaeba8b09053c2a9572",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 6674,
            "upload_time": "2024-03-14T06:44:14",
            "upload_time_iso_8601": "2024-03-14T06:44:14.068659Z",
            "url": "https://files.pythonhosted.org/packages/17/2f/a479c5e38ce50b6d6537d5488795466419ae9cc141ea262cd85e4f724424/graphi_crud-1.1.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-14 06:44:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "abelayalew",
    "github_project": "graphi",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "graphi_crud"
}
        
Elapsed time: 0.31024s