【发布时间】:2019-07-19 11:40:24
【问题描述】:
Basic info:后端使用 Postgres,前端使用 Postgraphile 使用 GraphQL。
Need:使用 GraphQL 突变更新 Postgres DB 中的一行。
Code:
假设我有一个 library_account 模式,它在 Postgres 中有 book 表,其中包含 id、title、borrower_id 和 is_available 等字段。
Scenario:这是第一次被借。
Proposed flow:进行 GraphQL 突变以使用 borrower_id 更新 Postgres 表。
我目前使用的代码:
mutation BookUpdates(
$title: String,
$borrower_id: Int!, #not really an Int but for the sake of ease.
$author_id: Int!,
$isle_id: Int!,
$is_available: Boolean
) {
updateBookByAuthorIdAndIsleId(input: {
isle_id: $isle_id,
is_available: $is_available,
borrower_id: $borrower_id,
author_id: $author_id
}) {
bookEdge {
node {
author_id
}
}
}
在这里,我收到了borrower_id 的错误,它说borrower_id 不是由updateBookByAuthorIdAndIsleId 类型定义的。
有什么建议吗??
【问题讨论】:
标签: database postgresql graphql mutation postgraphile