【发布时间】:2020-10-03 08:12:30
【问题描述】:
我正在尝试在 GraphQL 中实现突变。我正在使用 GraphQL Play Ground Ui 进行查询。
这是我的突变:
mutation{
createProduct (data :{
product: "abc",
product_status : {
"1" : {
order : "done"
}
}
这是我的 TypeDef
type Product {
product : String,
product_status : JSON
}
但我在 product_status excepted Name but found String 中遇到错误,因为对象包含 1 作为字符串。我该如何解决这个问题。我需要将这种类型的对象存储在我的数据库中。有人可以帮我解决这个问题。
【问题讨论】:
-
product_status不是JSON类型。事实上,GraphQL中没有这种类型,除非您创建自定义类型。product_status在您的第一个代码中 sn-p 看起来像一个对象,因此您需要为此创建一个自定义类型。
标签: node.js graphql syntax-error apollo apollo-server