Skip to content
ASGI support for the Tartiflette GraphQL engine
Python HTML Shell
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Add docs site (#94) Oct 31, 2019
img Update banner with tartiflette-asgi instead of tartiflette-starlette. F… Oct 29, 2019
scripts Update contributing guidelines (#96) Oct 31, 2019
tartiflette_asgi Fix GraphiQL subscriptions endpoint when using ASGI sub-mounting (#98) Nov 10, 2019
tests Fix GraphiQL subscriptions endpoint when using ASGI sub-mounting (#98) Nov 10, 2019
.gitignore Add site/ to .gitignore Oct 31, 2019
.travis.yml Setup tooling for docs site (#95) Oct 31, 2019
CHANGELOG.md Release 0.7.1 Oct 28, 2019
CONTRIBUTING.md Update contributing guidelines (#96) Oct 31, 2019
LICENSE setup project Apr 19, 2019
MANIFEST.in
README.md
mkdocs.yml Add docs site (#94) Oct 31, 2019
requirements.txt Add docs site (#94) Oct 31, 2019
setup.cfg Rename project to tartiflette-asgi (#82) Oct 27, 2019
setup.py Rename project to tartiflette-asgi (#82) Oct 27, 2019

README.md

tartiflette-asgi logo

Build status Package version Code style

tartiflette-asgi (previously tartiflette-starlette) is a wrapper that provides ASGI support for the Tartiflette Python GraphQL engine.

It is ideal for serving a GraphQL API over HTTP, or adding a GraphQL API endpoint to an existing ASGI application.

Full documentation is available at: https://tartiflette.github.io/tartiflette-asgi

Requirements

tartiflette-asgi is compatible with:

  • Python 3.6, 3.7 or 3.8.
  • Tartiflette 1.x.

Quickstart

First, install Tartiflette's external dependencies, as explained in the Tartiflette tutorial.

Then, you can install Tartiflette and tartiflette-asgi using pip:

pip install tartiflette "tartiflette-asgi==0.*"

You'll also need an ASGI web server. We'll use Uvicorn here:

pip install uvicorn

Create an application that exposes a TartifletteApp instance:

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:

uvicorn graphql:app

Make an HTTP request containing a GraphQL query:

curl http://localhost:8000/graphql -d '{ hello(name: "Chuck") }' -H "Content-Type: application/graphql"

You should get the following JSON response:

{"data": {"hello": "Hello, Chuck!"}}

Contributing

Want to contribute? Awesome! Be sure to read our Contributing guidelines.

Changelog

Changes to this project are recorded in the changelog.

License

MIT

You can’t perform that action at this time.