将graphql支持添加到webob(pyramid/pylons/…)应用程序中

WebOb-GraphQL的Python项目详细描述


Build StatusCoverage StatusPyPI version

将GraphQL支持添加到WebOB(金字塔、挂架…)应用程序中。

安装

要安装webob graphql,只需在shell中运行此命令

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

用法

只需使用webob_graphql

中的serve_graphql_request函数

金字塔

frompyramid.viewimportview_configfromwebob_graphqlimportserve_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 :))defgraphql_view(request):returnserve_graphql_request(request,schema)# Optional, for adding batch query support (used in Apollo-Client)returnserve_graphql_request(request,schema,batch_enabled=True)

支持的选项

  • schema:要视图的GraphQLSchema对象 在收到有效请求时执行。
  • context:作为context传递给^{tt7}的值。$ 功能。
  • root_value:要提供给的root_valueexecutor.execute
  • format_error:如果要使用自定义错误格式化程序。
  • pretty:是否希望正确打印响应 json。
  • executor:要用于执行的Executor。 询问。
  • graphiql_enabled:如果True(默认),则可能存在 GraphiQL加载时 直接从浏览器(用于调试和 探索)。
  • render_graphiql:用于呈现graphiql的自定义函数(这个 函数应该有参数resultparams
  • batch_enabled:启用批处理支持(用于 Apollo-ClientReactRelayNetworkLayer

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java http响应未定义   java在单个数组中添加浮点值和字符串值,并使用它们进行写入。CSV文件   映射中的java重复列引发实体异常,但没有重复列   java为什么是线程。stop()方法不安全吗?   如何在java中从trycatch块返回数组?   java如何使用多个线程作为客户端,每个线程都在switch语句中执行一项任务   Android GridView上的java滚动位置跳转   java丰富:listShuttle格式   Java中的macos评测本机方法奇怪的结果   这个Java程序需要是两个独立的文件吗   无法使用selenium Java或JavascriptExecutor发送密钥/单击   java如何配置Jetty在类更改时重新加载WebAppContext   java我不能发布com。安卓截击服务器错误   java如何在使用addOnScrollListener时显示滚动条   java如何避免数据模型贫乏?存储库可以注入实体吗?   没有集合的java选择排序。在ArrayList中排序   macos在MacOSX上升级JDK   java如何使用jpa模板编写查询