为您的WebOb (Pyramid/Pylons/...) 应用程序添加GraphQL支持
项目描述
为您的WebOb (Pyramid, Pylons, …) 应用程序添加GraphQL支持。
安装
要安装WebOb-GraphQL,只需在您的shell中运行此命令
pip install "webob-graphql>=1.0.dev"
用法
只需使用来自 webob_graphql 的 serve_graphql_request 函数
Pyramid
from pyramid.view import view_config
from webob_graphql import serve_graphql_request
@view_config(
route_name='graphql',
# The serve_graphql_request method will detect what's the best renderer
# to use, so it will do the json render automatically.
# In summary, don't use the renderer='json' here :)
)
def graphql_view(request):
return serve_graphql_request(request, schema)
# Optional, for adding batch query support (used in Apollo-Client)
return serve_graphql_request(request, schema, batch_enabled=True)
支持选项
schema:当视图接收到有效请求时,您想要执行的 GraphQLSchema 对象。
context:要传递给 graphql() 函数的值。
root_value:您想要提供给 executor.execute 的 root_value。
format_error:如果您想使用自定义错误格式化程序。
pretty:是否希望将响应格式化为漂亮的JSON。
executor:用于执行查询的Executor。
graphiql_enabled:如果为True(默认值),则可以从浏览器直接加载时显示GraphiQL(一个用于调试和探索的有用工具)。
render_graphiql:用于渲染GraphiQL的自定义函数(此函数应具有result和params参数)。
batch_enabled:启用批量支持(用于在Apollo-Client或ReactRelayNetworkLayer中使用)。
项目详情
关闭
WebOb-GraphQL-1.0.tar.gz的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 1e1f117bc923dd32862c61c7058dc2ba3104428d8e8713a1e27f0c4586378161 |
|
MD5 | 4ce46f650d538bd2792da630eeafde50 |
|
BLAKE2b-256 | a779e40d2c212e5c800716c182173ade1185cdb836dd60a3ab04e2316d8a9375 |