# Strawberry Jam 🍓
Codegen django command for strawberry-django for rapid schema boilerplate generation from given models
## Installation
```txt
pip3 install strawberry_jam
```
or using uv
```txt
uv pip install strawberry_jam
```
Add `'strawberry_jam'` to your project's `settings.py`.
```py
INSTALLED_APPS = [
# ... other apps
'strawberry_jam',
]
```
Configure strawberry django to handle GlobalIds automatically.
```py
STRAWBERRY_DJANGO = {
"MAP_AUTO_ID_AS_GLOBAL_ID": True
}
```
## Usage
```zsh
python3 manage.py configure-schema <app_label.ModelName1> <app_label.ModelName2> <app_label.ModelNameN> -in <my_graphql_app_label> -fl <flavor_name>
```
### Arguments
#### Required
1. list of models in form of `app_label.ModelName`
2. `--in-app`, `-in`: the `app_label` where the schema modules will be generated
3. `--flavor`, `-fl`, `--workflow`, `-wfl`: the name of the workflow that will generate the necessary modules
#### Optional
1. `--package-name`, `-pn`: the name of the package, defaults to `gql`
2. `--overwrite`, `-owt`: if true, will overwrite everything
## Falvors/Workflows
This addon comes with the following flavors:
- `relay_queries`: generates relay style types(nodes), query, filter, order
- `relay_mutations`: generates relay style create/partial-update input types, mutations
- `query_set_managers`: A simple class with get_queryset, to help manage querysets in one place, normally not needed
- `tests`: coming soon
IMPORTANT!
**Running a flavor with `overwrite` flag will replace the necessary modules made with other flavors to work with the currenty run flavor.**
## Under the hood and things to know
### StrawberryJamTemplate
The addon has implemented a simple `StrawberryJamTemplate` class. The command looks for modules in the `chunks/flavor_name/templates/` and initializes the Template subclass of `StrawberryJamTemplate`, which generates the necessary modules in the schema.
### Mutations
The relay_mutations flavor comes with extra. Instead of exposing to-many relations as a field, it exposes them via `<field_name>_add` and `<field_name>_remove` fields of type `list[GlobalID]`, which let add remove fields by simply passing ids that need to be added or removed.
## TODO
- Add generation of test modules
- Maybe add ability to run multiple flavors consecutively
- The generated schema will not work, if the types for relations are not generated. So maybe skip the fields for models that are not supplied to the command.
# MIT License
Copyright (c) 2024 Gevorg Hakobyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Raw data
{
"_id": null,
"home_page": "https://github.com/Elawphant/strawberry_jam",
"name": "strawberry_jam",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "graphql, django, strawberry-graphql-django, command",
"author": "Gevorg Hakobyan",
"author_email": "gevorg.hakobyan@elawphant.am",
"download_url": "https://files.pythonhosted.org/packages/c0/44/0ca53e622e7027d3fc5323cc398dd26ae66ce3a45061239ba3bde12916b7/strawberry_jam-1.1.0.tar.gz",
"platform": null,
"description": "# Strawberry Jam \ud83c\udf53\n\nCodegen django command for strawberry-django for rapid schema boilerplate generation from given models\n\n## Installation\n\n```txt\npip3 install strawberry_jam\n```\n\nor using uv\n\n```txt\nuv pip install strawberry_jam\n```\n\nAdd `'strawberry_jam'` to your project's `settings.py`.\n\n```py\nINSTALLED_APPS = [\n # ... other apps\n 'strawberry_jam',\n]\n```\n\nConfigure strawberry django to handle GlobalIds automatically.\n\n```py\nSTRAWBERRY_DJANGO = {\n \"MAP_AUTO_ID_AS_GLOBAL_ID\": True\n}\n```\n\n## Usage\n\n```zsh\npython3 manage.py configure-schema <app_label.ModelName1> <app_label.ModelName2> <app_label.ModelNameN> -in <my_graphql_app_label> -fl <flavor_name>\n```\n\n### Arguments\n\n#### Required\n\n1. list of models in form of `app_label.ModelName`\n2. `--in-app`, `-in`: the `app_label` where the schema modules will be generated\n3. `--flavor`, `-fl`, `--workflow`, `-wfl`: the name of the workflow that will generate the necessary modules\n\n#### Optional\n\n1. `--package-name`, `-pn`: the name of the package, defaults to `gql`\n2. `--overwrite`, `-owt`: if true, will overwrite everything\n\n## Falvors/Workflows\n\nThis addon comes with the following flavors:\n\n- `relay_queries`: generates relay style types(nodes), query, filter, order\n- `relay_mutations`: generates relay style create/partial-update input types, mutations\n- `query_set_managers`: A simple class with get_queryset, to help manage querysets in one place, normally not needed\n- `tests`: coming soon\n\nIMPORTANT!\n\n**Running a flavor with `overwrite` flag will replace the necessary modules made with other flavors to work with the currenty run flavor.**\n\n## Under the hood and things to know\n\n### StrawberryJamTemplate\n\nThe addon has implemented a simple `StrawberryJamTemplate` class. The command looks for modules in the `chunks/flavor_name/templates/` and initializes the Template subclass of `StrawberryJamTemplate`, which generates the necessary modules in the schema.\n\n### Mutations\n\nThe relay_mutations flavor comes with extra. Instead of exposing to-many relations as a field, it exposes them via `<field_name>_add` and `<field_name>_remove` fields of type `list[GlobalID]`, which let add remove fields by simply passing ids that need to be added or removed.\n\n## TODO\n\n- Add generation of test modules\n- Maybe add ability to run multiple flavors consecutively\n- The generated schema will not work, if the types for relations are not generated. So maybe skip the fields for models that are not supplied to the command.\n\n# MIT License\n\nCopyright (c) 2024 Gevorg Hakobyan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Codegen django command for strawberry-django for rapid schema boilerplate generation from given models",
"version": "1.1.0",
"project_urls": {
"Homepage": "https://github.com/Elawphant/strawberry_jam",
"Repository": "https://github.com/Elawphant/strawberry_jam"
},
"split_keywords": [
"graphql",
" django",
" strawberry-graphql-django",
" command"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6f114349a1d88a2ccc4e8ae3e9977cabe27fb6872565a889195bfafeabceca88",
"md5": "5b7264da82f5dab71ae96b300334eba1",
"sha256": "3e92d50aad2a7dc7d54f5dea92f632631d48277aee082346d83506d9759d8ea1"
},
"downloads": -1,
"filename": "strawberry_jam-1.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5b7264da82f5dab71ae96b300334eba1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 28303,
"upload_time": "2024-06-15T13:43:45",
"upload_time_iso_8601": "2024-06-15T13:43:45.964061Z",
"url": "https://files.pythonhosted.org/packages/6f/11/4349a1d88a2ccc4e8ae3e9977cabe27fb6872565a889195bfafeabceca88/strawberry_jam-1.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c0440ca53e622e7027d3fc5323cc398dd26ae66ce3a45061239ba3bde12916b7",
"md5": "a703b3249cb5366e252f6a569c88d4a6",
"sha256": "a0578d56079223c385cbfd1a194903d6783bda2a2ed0c0d79a4a1d1603c63d50"
},
"downloads": -1,
"filename": "strawberry_jam-1.1.0.tar.gz",
"has_sig": false,
"md5_digest": "a703b3249cb5366e252f6a569c88d4a6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 17068,
"upload_time": "2024-06-15T13:43:47",
"upload_time_iso_8601": "2024-06-15T13:43:47.444520Z",
"url": "https://files.pythonhosted.org/packages/c0/44/0ca53e622e7027d3fc5323cc398dd26ae66ce3a45061239ba3bde12916b7/strawberry_jam-1.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-15 13:43:47",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Elawphant",
"github_project": "strawberry_jam",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "strawberry-graphql-django",
"specs": []
},
{
"name": "django",
"specs": []
},
{
"name": "tqdm",
"specs": []
},
{
"name": "pytest",
"specs": []
}
],
"lcname": "strawberry_jam"
}