Skip to main content

GraphQL Engine for python

Project description

![Tartiflette](docs/github-landing.png)

**Tartiflette** is a GraphQL Server implementation built with **Python 3.6+**.

## Motivation

[Read this blogpost about our motivations](https://medium.com/dailymotion/tartiflette-graphql-api-engine-python-open-source-a200c5bbc477)
TL; DR
We reached the limits of Graphene, we wanted to build something which met certain requirements:
* **Offers a better developer experience** that respects the Python mindset
* **Uses SDL** _(Schema Definition Language)_
* Uses **asyncio** as the sole execution engine
* Be 100% open source

## Status

**The [first milestone](/docs/roadmaps/milestone-1.md) is behind us, we are now [on the road to the milestone 2](/docs/roadmaps/milestone-2.md)**.

**DNA**

* Define the **GraphQL schema** with the brand new [SDL _(Schema Definition Language)_](https://github.com/facebook/graphql/blob/master/spec/Section%203%20--%20Type%20System.md).
* **Performance oriented:** Performance is the core of our work.
* **Simple is better than complex:** Built with [the Zen of Python](https://www.python.org/dev/peps/pep-0020/#id3) in mind. No over-engineering.

Discover Tartiflette with our fabulous tutorial on [https://tartiflette.io/docs/tutorial/getting-started](https://tartiflette.io/docs/tutorial/getting-started)

**Summary**

- [Usage](#usage)
- [Installation](#installation)
- [Installation dependencies](#installation-dependencies)
- [Tartiflette over HTTP](#tartiflette-over-http)
- [Roadmaps](#roadmaps)
- [Known issues](#known-issues)

## Usage

```python
import asyncio

from tartiflette import Engine, Resolver

@Resolver("Query.hello")
async def resolver_hello(parent, args, ctx, info):
return "hello " + args["name"]


async def run():
tftt_engine = Engine("""
type Query {
hello(name: String): String
}
""")

result = await tftt_engine.execute(
query='query { hello(name: "Chuck") }'
)

print(result)
# {'data': {'hello': 'hello Chuck'}}

if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```

More details on the [API Documentation](https://tartiflette.io/docs/api/engine/)

## Installation

Tartiflette is available on [pypi.org](https://pypi.org/project/tartiflette/).

```bash
pip install tartiflette
```

### Installation dependencies

As Tartiflette based its Executor engine on *[libgraphqlparser](https://github.com/graphql/libgraphqlparser)*. You'll need these following commands on your environment to use the library. `cmake`, `bison` and `flex`.

*MacOSX*
```bash
brew install cmake flex bison
```

*Ubuntu*
```bash
apt-get install cmake flex bison
```

## Tartiflette over HTTP

Discover our implementation of tartiflette over HTTP called [tartiflette-aiohttp](https://github.com/dailymotion/tartiflette-aiohttp).

**Overview**
```bash
pip install tartiflette-aiohttp
```

```python
from aiohttp import web
from tartiflette_aiohttp import register_graphql_handlers

sdl = """
type Query {
hello(name: String): String
}
"""

ctx = {
'user_service': user_service
}

web.run_app(
register_graphql_handlers(
app=web.Application(),
engine_sdl=sdl,
engine_schema_name="default",
executor_context=ctx,
executor_http_endpoint='/graphql',
executor_http_methods=['POST', 'GET']
)
)
```

## Roadmaps

* [Milestone 1 _(Released)_](/docs/roadmaps/milestone-1.md)
* [Milestone 2 - **Work in progress**](/docs/roadmaps/milestone-2.md)

## How to contribute to the documentation?

As you may know, the documentation is hosted on https://tartiflette.io. This _fabulous_ website is built thanks to another amazing tool, [docusaurus](https://docusaurus.io/).

The content of the documentation is hosted in this repository, to be as close as possible to the code. You will find everything you need/want in the folder `/docs`.

### How to run the website locally?

We built a docker image for the documentation _(dailymotion/tartiflette.io on docker hub)_, which allow us to provide you an easy way to launch the documentation locally, without installing a specific version of node.

**prerequisite**:
- Docker
- Docker Compose
- Make

```bash
make run-docs
```

Every change you will make in the `/docs` folder will be automatically hot reloaded. :tada:

## Known issues

* [Schema directives aren't executed](https://github.com/dailymotion/tartiflette/issues/134)

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tartiflette-0.6.10.tar.gz (134.5 kB view details)

Uploaded Source

File details

Details for the file tartiflette-0.6.10.tar.gz.

File metadata

  • Download URL: tartiflette-0.6.10.tar.gz
  • Upload date:
  • Size: 134.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for tartiflette-0.6.10.tar.gz
Algorithm Hash digest
SHA256 31441c91ca326ac029e1ab9c743947faf53548d72c99706309c4b1d7a682b902
MD5 62d52981e6f16945794bb4a2a5cb5fdf
BLAKE2b-256 978a7fa0bd8dcf1184332142d81128905d1674f099ba64df909068c3733cc068

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page