Name | wagtail-grapple JSON |
Version |
0.26.0
JSON |
| download |
home_page | None |
Summary | A Wagtail package that speeds up and simplifies implementing a GraphQL endpoint! |
upload_time | 2024-06-26 10:39:30 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.8 |
license | None |
keywords |
wagtail
django
graphql
graphene
api
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
|
<p align="center">
<a href="https://github.com/torchbox/wagtail-grapple">
<img src="https://github.com/torchbox/wagtail-grapple/raw/main/.github/wagtail-grapple.svg?sanitize=true" alt="A red g with a grapple hook" width="80" height="80">
</a>
</p>
# Wagtail Grapple
[![Build status](https://github.com/torchbox/wagtail-grapple/actions/workflows/ci.yml/badge.svg)](https://github.com/torchbox/wagtail-grapple/actions)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![PyPi](https://img.shields.io/pypi/v/wagtail-grapple.svg)](https://pypi.org/project/wagtail-grapple/)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/torchbox/wagtail-grapple/main.svg)](https://results.pre-commit.ci/latest/github/torchbox/wagtail-grapple/main)
A library to build GraphQL endpoints easily so you can grapple your Wagtail data from anywhere!
[Explore the docs »](https://wagtail-grapple.readthedocs.io/en/latest/) ·
[Report Bug](https://github.com/torchbox/wagtail-grapple/issues) ·
[Request Feature](https://github.com/torchbox/wagtail-grapple/issues)
## About The Project
There is a range of GraphQL packages for Python and specifically Django.
However, getting these packages to work out of the box with an existing infrastructure
without errors isn't as easy to come by.
The purpose of Grapple is to be able to build GraphQL endpoints on a model by model
basis as quickly as possible. The setup and configuration have been designed
to be as simple but also provide the best features;
No complex serializers need to be written - just add a `graphql_fields` list
to your model and away you go (although if you want to go deeper you can!).
### Features
- Easily create GraphQL types by adding a small annotation in your models.
- Supports traditional Wagtail models:
- Pages (including StreamField & Orderables)
- Snippets
- Images
- Documents
- Media (via [wagtailmedia](https://pypi.org/project/wagtailmedia/))
- Settings
- Redirects
- Search (on all models)
- Custom Image & Document model support
- Pagination support
- Middleware support
### Built With
This library is an abstraction upon and relies heavily on Graphene & Graphene Django.
- [Graphene](https://github.com/graphql-python/graphene)
- [Graphene Django](https://github.com/graphql-python/graphene)
## Getting Started
Getting Grapple installed is designed to be as simple as possible!
### Prerequisites
```
Python >= 3.8
Wagtail >= 5.2
Django >= 4.2
```
### Installation
Install using pip
```bash
python -m pip install wagtail_grapple
```
Add the following to the `INSTALLED_APPS` list in your Wagtail settings file:
```python
INSTALLED_APPS = [
# ...
"grapple",
"graphene_django",
# ...
]
```
Add the following to the bottom of the same settings file, where each key is the app you want to this library to scan and the value is the prefix you want to give to GraphQL types (you can usually leave this blank):
```python
# Grapple config:
GRAPHENE = {"SCHEMA": "grapple.schema.schema"}
GRAPPLE = {
"APPS": ["home"],
}
```
Add the GraphQL URLs to your `urls.py`:
```python
from django.urls import include, path
from grapple import urls as grapple_urls
# ...
urlpatterns = [
# ...
path("api/", include(grapple_urls)),
# ...
]
```
Done! Now you can proceed onto configuring your models to generate GraphQL types that adopt their structure :tada:
_Your GraphQL endpoint is available at [http://localhost:8000/api/graphql/](http://localhost:8000/api/graphql/)_
## Usage
Here is a GraphQL model configuration for the default page from the Wagtail docs:
```python
# ...
from grapple.models import GraphQLString, GraphQLStreamfield
class BlogPage(Page):
author = models.CharField(max_length=255)
date = models.DateField("Post date")
body = StreamField(
[
("heading", blocks.CharBlock(classname="full title")),
("paragraph", blocks.RichTextBlock()),
("image", ImageChooserBlock()),
]
)
content_panels = Page.content_panels + [
FieldPanel("author"),
FieldPanel("date"),
StreamFieldPanel("body"),
]
# Note these fields below:
graphql_fields = [
GraphQLString("heading"),
GraphQLString("date"),
GraphQLString("author"),
GraphQLStreamfield("body"),
]
```
_For more examples, please refer to the [Documentation](https://wagtail-grapple.readthedocs.io/en/latest/)_
## Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create.
Any contributions [you make](https://github.com/torchbox/wagtail-grapple/graphs/contributors) are **greatly appreciated**.
1. Fork the project
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Open a Pull Request
### Local development
- In the Python environment of your choice, navigate to `tests/`
- Run `python -m pip install -r requirements.txt`
- Run `python manage.py migrate`
- Run server `python manage.py runserver`
- Run tests `python manage.py test`
#### With Postgres
- Ensure you have docker and docker compose
- Run `docker compose up`
- Run `export DATABASE_URL="postgres://postgres:postgres@localhost/postgres"`
- In the Python environment of your choice, navigate to `tests/`
- Run `python -m pip install -r requirements.txt`
- Run `python manage.py migrate`
- Run server `python manage.py runserver`
- Run tests `python manage.py test`
## Compatibility
Wagtail Grapple supports:
- Python 3.8, 3.9, 3.10 3.11 and 3.12
- Wagtail >= 5.2
## License
Distributed under the MIT License. See `LICENSE` for more information.
<!-- ACKNOWLEDGEMENTS -->
## Inspired by
- [@tr11](https://github.com/tr11)
- [@tmkn](https://github.com/tmkn)
Raw data
{
"_id": null,
"home_page": null,
"name": "wagtail-grapple",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "Dan Braghis <dan.braghis@torchbox.com>",
"keywords": "wagtail, django, graphql, graphene, api",
"author": null,
"author_email": "Nathan Horrigan <hello@torchbox.com>",
"download_url": "https://files.pythonhosted.org/packages/fc/36/2ad789a09d78b786eccf359ff88a596bcacfff4b9dd6505b68ad3c7f62f5/wagtail_grapple-0.26.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <a href=\"https://github.com/torchbox/wagtail-grapple\">\n <img src=\"https://github.com/torchbox/wagtail-grapple/raw/main/.github/wagtail-grapple.svg?sanitize=true\" alt=\"A red g with a grapple hook\" width=\"80\" height=\"80\">\n </a>\n</p>\n\n# Wagtail Grapple\n\n[![Build status](https://github.com/torchbox/wagtail-grapple/actions/workflows/ci.yml/badge.svg)](https://github.com/torchbox/wagtail-grapple/actions)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![PyPi](https://img.shields.io/pypi/v/wagtail-grapple.svg)](https://pypi.org/project/wagtail-grapple/)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/torchbox/wagtail-grapple/main.svg)](https://results.pre-commit.ci/latest/github/torchbox/wagtail-grapple/main)\n\nA library to build GraphQL endpoints easily so you can grapple your Wagtail data from anywhere!\n\n[Explore the docs \u00bb](https://wagtail-grapple.readthedocs.io/en/latest/) \u00b7\n[Report Bug](https://github.com/torchbox/wagtail-grapple/issues) \u00b7\n[Request Feature](https://github.com/torchbox/wagtail-grapple/issues)\n\n## About The Project\n\nThere is a range of GraphQL packages for Python and specifically Django.\nHowever, getting these packages to work out of the box with an existing infrastructure\nwithout errors isn't as easy to come by.\n\nThe purpose of Grapple is to be able to build GraphQL endpoints on a model by model\nbasis as quickly as possible. The setup and configuration have been designed\nto be as simple but also provide the best features;\nNo complex serializers need to be written - just add a `graphql_fields` list\nto your model and away you go (although if you want to go deeper you can!).\n\n### Features\n\n- Easily create GraphQL types by adding a small annotation in your models.\n- Supports traditional Wagtail models:\n - Pages (including StreamField & Orderables)\n - Snippets\n - Images\n - Documents\n - Media (via [wagtailmedia](https://pypi.org/project/wagtailmedia/))\n - Settings\n - Redirects\n - Search (on all models)\n- Custom Image & Document model support\n- Pagination support\n- Middleware support\n\n### Built With\n\nThis library is an abstraction upon and relies heavily on Graphene & Graphene Django.\n\n- [Graphene](https://github.com/graphql-python/graphene)\n- [Graphene Django](https://github.com/graphql-python/graphene)\n\n## Getting Started\n\nGetting Grapple installed is designed to be as simple as possible!\n\n### Prerequisites\n\n```\nPython >= 3.8\nWagtail >= 5.2\nDjango >= 4.2\n```\n\n### Installation\n\nInstall using pip\n\n```bash\npython -m pip install wagtail_grapple\n```\n\nAdd the following to the `INSTALLED_APPS` list in your Wagtail settings file:\n\n```python\nINSTALLED_APPS = [\n # ...\n \"grapple\",\n \"graphene_django\",\n # ...\n]\n```\n\nAdd the following to the bottom of the same settings file, where each key is the app you want to this library to scan and the value is the prefix you want to give to GraphQL types (you can usually leave this blank):\n\n```python\n# Grapple config:\nGRAPHENE = {\"SCHEMA\": \"grapple.schema.schema\"}\nGRAPPLE = {\n \"APPS\": [\"home\"],\n}\n```\n\nAdd the GraphQL URLs to your `urls.py`:\n\n```python\nfrom django.urls import include, path\nfrom grapple import urls as grapple_urls\n\n# ...\nurlpatterns = [\n # ...\n path(\"api/\", include(grapple_urls)),\n # ...\n]\n```\n\nDone! Now you can proceed onto configuring your models to generate GraphQL types that adopt their structure :tada:\n_Your GraphQL endpoint is available at [http://localhost:8000/api/graphql/](http://localhost:8000/api/graphql/)_\n\n## Usage\n\nHere is a GraphQL model configuration for the default page from the Wagtail docs:\n\n```python\n# ...\nfrom grapple.models import GraphQLString, GraphQLStreamfield\n\n\nclass BlogPage(Page):\n author = models.CharField(max_length=255)\n date = models.DateField(\"Post date\")\n body = StreamField(\n [\n (\"heading\", blocks.CharBlock(classname=\"full title\")),\n (\"paragraph\", blocks.RichTextBlock()),\n (\"image\", ImageChooserBlock()),\n ]\n )\n\n content_panels = Page.content_panels + [\n FieldPanel(\"author\"),\n FieldPanel(\"date\"),\n StreamFieldPanel(\"body\"),\n ]\n\n # Note these fields below:\n graphql_fields = [\n GraphQLString(\"heading\"),\n GraphQLString(\"date\"),\n GraphQLString(\"author\"),\n GraphQLStreamfield(\"body\"),\n ]\n```\n\n_For more examples, please refer to the [Documentation](https://wagtail-grapple.readthedocs.io/en/latest/)_\n\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create.\nAny contributions [you make](https://github.com/torchbox/wagtail-grapple/graphs/contributors) are **greatly appreciated**.\n\n1. Fork the project\n2. Create your feature branch (`git checkout -b feature/amazing-feature`)\n3. Commit your changes (`git commit -m 'Add some amazing feature'`)\n4. Push to the branch (`git push origin feature/amazing-feature`)\n5. Open a Pull Request\n\n### Local development\n\n- In the Python environment of your choice, navigate to `tests/`\n- Run `python -m pip install -r requirements.txt`\n- Run `python manage.py migrate`\n- Run server `python manage.py runserver`\n- Run tests `python manage.py test`\n\n#### With Postgres\n\n- Ensure you have docker and docker compose\n- Run `docker compose up`\n- Run `export DATABASE_URL=\"postgres://postgres:postgres@localhost/postgres\"`\n- In the Python environment of your choice, navigate to `tests/`\n- Run `python -m pip install -r requirements.txt`\n- Run `python manage.py migrate`\n- Run server `python manage.py runserver`\n- Run tests `python manage.py test`\n\n## Compatibility\n\nWagtail Grapple supports:\n\n- Python 3.8, 3.9, 3.10 3.11 and 3.12\n- Wagtail >= 5.2\n\n## License\n\nDistributed under the MIT License. See `LICENSE` for more information.\n\n<!-- ACKNOWLEDGEMENTS -->\n\n## Inspired by\n\n- [@tr11](https://github.com/tr11)\n- [@tmkn](https://github.com/tmkn)\n\n",
"bugtrack_url": null,
"license": null,
"summary": "A Wagtail package that speeds up and simplifies implementing a GraphQL endpoint!",
"version": "0.26.0",
"project_urls": {
"Changelog": "https://github.com/torchbox/wagtail-grapple/blob/main/CHANGELOG.md",
"Documentation": "https://wagtail-grapple.readthedocs.io/en/latest/"
},
"split_keywords": [
"wagtail",
" django",
" graphql",
" graphene",
" api"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a81189560b651d61d71c81841f56249dcea3ab441bfcb2adb5afe7b5e516085",
"md5": "6df6c2c61779a26c1380e06ac937d6c7",
"sha256": "de9d3c336d151279976d67f781c758ac5efc7d2bb003c2e311e6fbeea1554c41"
},
"downloads": -1,
"filename": "wagtail_grapple-0.26.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6df6c2c61779a26c1380e06ac937d6c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 47759,
"upload_time": "2024-06-26T10:39:28",
"upload_time_iso_8601": "2024-06-26T10:39:28.849747Z",
"url": "https://files.pythonhosted.org/packages/7a/81/189560b651d61d71c81841f56249dcea3ab441bfcb2adb5afe7b5e516085/wagtail_grapple-0.26.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fc362ad789a09d78b786eccf359ff88a596bcacfff4b9dd6505b68ad3c7f62f5",
"md5": "bdd5ac18539ae80fab50f2cbc74cc775",
"sha256": "68be091f7feb95bfbe0377bd03c1814a64a6150ae964ec593670d995f11780e5"
},
"downloads": -1,
"filename": "wagtail_grapple-0.26.0.tar.gz",
"has_sig": false,
"md5_digest": "bdd5ac18539ae80fab50f2cbc74cc775",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 38362,
"upload_time": "2024-06-26T10:39:30",
"upload_time_iso_8601": "2024-06-26T10:39:30.511307Z",
"url": "https://files.pythonhosted.org/packages/fc/36/2ad789a09d78b786eccf359ff88a596bcacfff4b9dd6505b68ad3c7f62f5/wagtail_grapple-0.26.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-26 10:39:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "torchbox",
"github_project": "wagtail-grapple",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"tox": true,
"lcname": "wagtail-grapple"
}