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
- Define the GraphQL schema with the brand new SDL (Schema Definition Language).
- Performance oriented: Performance is the core of our work.
- Simple is better than complex: Built with the Zen of Python in mind. No over-engineering.
Discover Tartiflette with our fabulous tutorial on https://tartiflette.io/docs/tutorial/getting-started
Summary
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
Tartiflette is available on pypi.org.
pip install tartiflette
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
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']
)
)