语法错误 GraphQL 预期名称,找到字符串

Syntax Error GraphQL Expected Name, found String

我正在尝试在 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 中收到错误,但发现 String 作为对象包含 1 作为字符串。我该如何解决这个问题。我需要将这种类型的对象存储在我的 database.Can 有人帮助我做到这一点。

Error Image

GraphQL 支持严格的数据类型化。所以基本上你不能将字符串作为 属性 键,因为那意味着它不知道要反序列化成什么。另外我不确定 JSON 是否是一种数据类型。我知道字符串和类型,但不知道 JSON。你可以有一个像这样的对象:

type Product { 
    product : String,
    product_status : ProductStatus
}

type ProductStatus {
    id: ID,
    order: String,
}

这就是您可以设计的方式。