Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tartiflette/tartiflette-asgi
ASGI support for the Tartiflette GraphQL engine
https://github.com/tartiflette/tartiflette-asgi
asgi async graphql http python starlette websocket
Last synced: 2 months ago
JSON representation
ASGI support for the Tartiflette GraphQL engine
- Host: GitHub
- URL: https://github.com/tartiflette/tartiflette-asgi
- Owner: tartiflette
- License: mit
- Created: 2019-04-19T19:38:45.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-26T07:57:25.000Z (over 1 year ago)
- Last Synced: 2024-05-20T01:16:07.427Z (8 months ago)
- Topics: asgi, async, graphql, http, python, starlette, websocket
- Language: Python
- Homepage: https://tartiflette.github.io/tartiflette-asgi
- Size: 2.84 MB
- Stars: 99
- Watchers: 8
- Forks: 16
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-asgi - tartiflette-asgi - ASGI support for the Tartiflette GraphQL engine. (GraphQL)
- awesome-python-resources - GitHub - 12% open · ⏱️ 20.05.2022): (GraphQL)
README
`tartiflette-asgi` is a wrapper that provides ASGI support for the [Tartiflette](https://tartiflette.io) Python GraphQL engine.
It is ideal for serving a GraphQL API over HTTP, or adding a GraphQL API endpoint to an existing ASGI application (e.g. FastAPI, Starlette, Quart, etc).
Full documentation is available at: https://tartiflette.github.io/tartiflette-asgi
## Requirements
`tartiflette-asgi` is compatible with:
- Python 3.6+.
- Tartiflette 1.x.## Quickstart
First, install Tartiflette's external dependencies, as explained in the [Tartiflette tutorial](https://tartiflette.io/docs/tutorial/install-tartiflette).
Then, you can install Tartiflette and `tartiflette-asgi` using `pip`:
```bash
pip install tartiflette "tartiflette-asgi==0.*"
```You'll also need an [ASGI web server](https://github.com/florimondmanca/awesome-asgi#servers). We'll use [Uvicorn](http://www.uvicorn.org/) here:
```bash
pip install uvicorn
```Create an application that exposes a `TartifletteApp` instance:
```python
from tartiflette import Resolver
from tartiflette_asgi import TartifletteApp@Resolver("Query.hello")
async def hello(parent, args, context, info):
name = args["name"]
return f"Hello, {name}!"sdl = "type Query { hello(name: String): String }"
app = TartifletteApp(sdl=sdl, path="/graphql")
```Save this file as `graphql.py`, then start the server:
```bash
uvicorn graphql:app
```Make an HTTP request containing a GraphQL query:
```bash
curl http://localhost:8000/graphql -d '{ hello(name: "Chuck") }' -H "Content-Type: application/graphql"
```You should get the following JSON response:
```json
{ "data": { "hello": "Hello, Chuck!" } }
```To learn more about using `tartiflette-asgi`, head to the documentation: https://tartiflette.github.io/tartiflette-asgi
## Contributing
Want to contribute? Awesome! Be sure to read our [Contributing guidelines](https://github.com/tartiflette/tartiflette-asgi/tree/master/CONTRIBUTING.md).
## Changelog
Changes to this project are recorded in the [changelog](https://github.com/tartiflette/tartiflette-asgi/tree/master/CHANGELOG.md).
## License
MIT