Skip to content

Instantly share code, notes, and snippets.

@tsunammis
Created March 9, 2019 08:37
Show Gist options
  • Save tsunammis/786baf25f1ed2ee1c6dc89ab9d3351f2 to your computer and use it in GitHub Desktop.
Save tsunammis/786baf25f1ed2ee1c6dc89ab9d3351f2 to your computer and use it in GitHub Desktop.
Introducing Tartiflette: dailymotion's Open Source GraphQL Implementation for Python 3.6+
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():
ttftt = Engine("""
type Query {
hello(name: String): String
}
""")
result = await ttftt.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())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment