Node.js 语法错误GraphQL应为名称,找到字符串

Node.js 语法错误GraphQL应为名称,找到字符串,node.js,graphql,syntax-error,apollo,apollo-server,Node.js,Graphql,Syntax Error,Apollo,Apollo Server,我试图在GraphQL中实现突变。我正在使用GraphQL Play Ground Ui进行查询 以下是我的看法: mutation{ createProduct (data :{ product: "abc", product_status : { "1" : { order : "done" } } 这是我的打字机 type Product { product : String, product_status : JSON }

我试图在GraphQL中实现突变。我正在使用GraphQL Play Ground Ui进行查询

以下是我的看法:

mutation{
  createProduct (data :{
     product: "abc", 
     product_status : {
      "1" : {
      order : "done"    
}

}
这是我的打字机

type Product { 
product : String,
product_status : JSON
}
但我在product_status中得到错误,例外名称,但发现字符串,因为对象包含1作为字符串。我怎样才能解决这个问题。我需要在我的数据库中存储这种类型的对象。有人能帮我吗


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

type Product { 
    product : String,
    product_status : ProductStatus
}

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

这就是你可以设计它的方式

product\u status
不是类型
JSON
。事实上,
GraphQL
中没有这样的类型,除非您创建一个自定义类型<第一个代码段中的代码>产品状态看起来像一个对象,因此需要为此创建自定义类型。