Skip to content

larsblumberg/tartiflette

 
 

Repository files navigation

Tartiflette

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

The first milestone is behind us, we are now on the road to the milestone 2.

DNA

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

Summary

Usage

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

Installation

Tartiflette is available on pypi.org.

pip install tartiflette

Installation dependencies

As Tartiflette based its Executor engine on libgraphqlparser. You'll need these following commands on your environment to use the library. cmake, bison and flex.

MacOSX

brew install cmake flex bison

Ubuntu

apt-get install cmake flex bison

Tartiflette over HTTP

Discover our implementation of tartiflette over HTTP called tartiflette-aiohttp.

Overview

pip install tartiflette-aiohttp
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

Known issues

About

GraphQL Engine built with Python 3.6+ / asyncio

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 99.8%
  • Makefile 0.2%