python的graphql引擎
tartiflette的Python项目详细描述
tartiflette是用python 3.6+构建的graphql服务器实现。
动机
Read this blogpost about our motivations TL;博士 我们达到了石墨烯的极限,我们想建造一些满足特定要求的东西:
- 提供了更好的开发人员体验尊重python思想
- 使用sdl (模式定义语言)
- 使用asyncio作为唯一的执行引擎
- 100%开源
状态
first milestone在我们后面,我们现在是on the road to the milestone 2。
dna
- 用全新的SDL (Schema Definition Language)定义graphql模式。
- performance-oriented:性能是我们工作的核心。
- simple比complex好:构建时考虑到the Zen of Python。不要过度设计。
通过我们关于https://tartiflette.io/docs/tutorial/getting-started的精彩教程,您可以发现馅饼
摘要
用法
importasynciofromtartifletteimportResolver,create_engine@Resolver("Query.hello")asyncdefresolver_hello(parent,args,ctx,info):return"hello "+args["name"]asyncdefrun():engine=awaitcreate_engine(""" type Query { hello(name: String): String } """)result=awaitengine.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())
有关API Documentation的更多详细信息
安装
在pypi.org上提供馅饼。
pip install tartiflette
安装依赖项
因为tartiflette的执行引擎基于libgraphqlparser。在您的环境中,需要使用以下命令才能使用库。cmake
、bison
和flex
。
macosx
brew install cmake flex bison
ubuntu
apt-get install cmake flex bison
http上的tartiflette
探索我们通过http实现的tartiflette,称为tartiflette-aiohttp。
概述
pip install tartiflette-aiohttp
fromaiohttpimportwebfromtartiflette_aiohttpimportregister_graphql_handlerssdl=""" 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']))
路线图
如何为文档做出贡献?
如您所知,文档托管在https://tartiflette.io。这个Fabeous网站的建立要感谢另一个令人惊叹的工具docusaurus。
文档的内容托管在这个存储库中,尽可能靠近代码。您将在文件夹/docs
中找到所需的一切。
如何在本地运行网站?
我们为文档(docker hub上的tartiflette/tartiflette.io)构建了一个docker映像,它允许我们提供一种在本地启动文档的简单方法,而无需安装特定版本的node。
先决条件:
- 码头工人
- Docker撰写
- 制造
make run-docs
您在/docs
文件夹中所做的每一个更改都将自动热重新加载。:tada: