Skip to content

Latest commit

 

History

History
38 lines (33 loc) · 931 Bytes

File metadata and controls

38 lines (33 loc) · 931 Bytes
name description url github
Tartiflette
A Python 3.6+ _(asyncio)_ library for building GraphQL APIs.
tartiflette/tartiflette

To run a tartiflette hello world script:

pip install tartiflette

Then run python hello.py with this code in hello.py:

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())

There is also a nice HTTP wrapper.