跳转到主要内容

为您的WebOb (Pyramid/Pylons/...) 应用程序添加GraphQL支持

项目描述

Build Status Coverage Status PyPI version

为您的WebOb (Pyramid, Pylons, …) 应用程序添加GraphQL支持。

安装

要安装WebOb-GraphQL,只需在您的shell中运行此命令

pip install "webob-graphql>=1.0.dev"

用法

只需使用来自 webob_graphqlserve_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.executeroot_value

  • format_error:如果您想使用自定义错误格式化程序。

  • pretty:是否希望将响应格式化为漂亮的JSON。

  • executor:用于执行查询的Executor

  • graphiql_enabled:如果为True(默认值),则可以从浏览器直接加载时显示GraphiQL(一个用于调试和探索的有用工具)。

  • render_graphiql:用于渲染GraphiQL的自定义函数(此函数应具有resultparams参数)。

  • batch_enabled:启用批量支持(用于在Apollo-ClientReactRelayNetworkLayer中使用)。

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源分布

WebOb-GraphQL-1.0.tar.gz (7.3 kB 查看哈希

上传时间:

支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面