Python:Graphene(服务端)
graphql-github-io-zh-Hans生态项目与库
Python:Graphene(服务端)
| 属性 | 值 |
|---|---|
| 名称 | Graphene |
| 描述 | 用于构建 GraphQL API 的 Python 库。 |
| 官网 | http://graphene-python.org/ |
| GitHub | graphql-python/graphene |
要运行 Graphene 的 hello world 脚本:
bash
pip install graphene
然后在 hello.py 中写入以下代码并运行 python hello.py:
python
import graphene
class Query(graphene.ObjectType):
hello = graphene.String(name=graphene.String(default_value="World"))
def resolve_hello(self, info, name):
return 'Hello ' + name
schema = graphene.Schema(query=Query)
result = schema.execute('{ hello }')
print(result.data['hello']) # "Hello World"
还提供了针对 Relay、Django、SQLAlchemy 和 Google App Engine 的优秀绑定。
帮助我们改进文档
发现翻译问题或内容错误?请告诉我们。
