【问题标题】:Postgraphile VS custom graphql resolver/schema in express server快递服务器中的 Postgraphile VS 自定义 graphql 解析器/模式
【发布时间】:2021-08-27 03:52:54
【问题描述】:

我正在尝试使用 Postgraphile,它是自动生成 GraphQL API 的好工具,但我仍然有点困惑为什么要使用它。 (P.S. 我对 GraphQL 和 PostgreSQL 不是很有经验。)

问题 1: 我可以这样想吗? Postgraphile 为服务器生成代码(查询、突变、解析器、模式、类型),如果我们不使用 Postgraphile,这些代码就是我们要编写的代码?

问题 2: 例如,服务器从前端接收到字符串James,我想将Bond 连接到它,然后再将其存储在数据库的全名列中。我如何实现这种突变?我需要makeExtendSchemaPlugin 来将我的架构与 Postgraphile 中的解析器合并吗?

【问题讨论】:

    标签: graphql express-graphql postgraphile


    【解决方案1】:

    问题 1:Postgraphile 为服务器生成代码(查询、变异、解析器、模式、类型),如果我们不使用 Postgraphile,这些代码就是我们要编写的代码

    正确。 postgraphile 将创建经过优化的 CRUD 操作和许多其他您需要实现的功能。

    问题 2:例如,服务器从前端接收字符串 James,我想在将其存储到数据库的全名列之前将其连接到它。我如何实现这种突变?

    您可以创建 postgreSQL 函数并实现业务逻辑。 https://www.graphile.org/postgraphile/custom-mutations/

    【讨论】:

      猜你喜欢
      • 2020-07-14
      • 2021-12-22
      • 1970-01-01
      • 2020-10-04
      • 2019-02-08
      • 2012-08-09
      • 1970-01-01
      • 2018-05-13
      • 2021-01-06
      相关资源
      最近更新 更多