Strawberry Jam 🍓
Codegen django command for strawberry-django for rapid schema boilerplate generation from given models
Installation
pip3 install strawberry_jam
or using uv
uv pip install strawberry_jam
Add 'strawberry_jam' to your project's settings.py.
INSTALLED_APPS = [
# ... other apps
'strawberry_jam',
]
Configure strawberry django to handle GlobalIds automatically.
STRAWBERRY_DJANGO = {
"MAP_AUTO_ID_AS_GLOBAL_ID": True
}
Usage
python3 manage.py configure-schema <app_label.ModelName1> <app_label.ModelName2> <app_label.ModelNameN> -in <my_graphql_app_label> -fl <flavor_name>
Arguments
Required
- list of models in form of
app_label.ModelName --in-app,-in: theapp_labelwhere the schema modules will be generated--flavor,-fl,--workflow,-wfl: the name of the workflow that will generate the necessary modules
Optional
--package-name,-pn: the name of the package, defaults togql--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, orderrelay_mutations: generates relay style create/partial-update input types, mutationsquery_set_managers: A simple class with get_queryset, to help manage querysets in one place, normally not neededtests: 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.
Metadata
Release files for strawberry_jam 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| strawberry_jam-1.1.0.tar.gz | 17.1 kB | Without provenance | Details for strawberry_jam-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| strawberry_jam-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for strawberry_jam-1.1.0-py3-none-any.whl |
Total release size: 45.4 kB
Release files / strawberry_jam-1.1.0.tar.gz
| Download URL | strawberry_jam-1.1.0.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0578d56079223c385cbfd1a194903d6783bda2a2ed0c0d79a4a1d1603c63d50
|
|
BLAKE2b-256 checksum How to use checksums |
c0440ca53e622e7027d3fc5323cc398dd26ae66ce3a45061239ba3bde12916b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.2 Darwin/23.5.0
|
Release files / strawberry_jam-1.1.0-py3-none-any.whl
| Download URL | strawberry_jam-1.1.0-py3-none-any.whl |
|---|---|
| Size | 28.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3e92d50aad2a7dc7d54f5dea92f632631d48277aee082346d83506d9759d8ea1
|
|
BLAKE2b-256 checksum How to use checksums |
6f114349a1d88a2ccc4e8ae3e9977cabe27fb6872565a889195bfafeabceca88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.12.2 Darwin/23.5.0
|
Security for strawberry_jam 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.