[英]Syntax Error GraphQL Expected Name, found String
I am trying to implement mutations in GraphQL.我正在尝试在 GraphQL 中实现突变。 I am using GraphQL Play Ground Ui for query.
我正在使用 GraphQL Play Ground Ui 进行查询。
Here is my mutation:这是我的突变:
mutation{
createProduct (data :{
product: "abc",
product_status : {
"1" : {
order : "done"
}
}
Here is my TypeDef这是我的 TypeDef
type Product {
product : String,
product_status : JSON
}
But I am getting error in product_status excepted Name but found String as object contains 1 as string.但是我在 product_status excepted Name 中遇到错误,但发现 String as object contains 1 as string。 How can i resolve this.
我该如何解决这个问题。 I need to store this type of object in My database.Can someone help me to this.
我需要将这种类型的 object 存储在我的数据库中。有人可以帮我解决这个问题。
GraphQL supports strict data typing. GraphQL 支持严格的数据类型。 So basically you can't have a string as a property key because that would mean it wouldn't know what to deserialize into.
所以基本上你不能将字符串作为属性键,因为这意味着它不知道要反序列化成什么。 Also I'm not sure if JSON is a data type.
另外我不确定 JSON 是否是一种数据类型。 I know strings and types but not JSON.
我知道字符串和类型,但不知道 JSON。 You coudld have a object like:
你可以有一个 object 像:
type Product {
product : String,
product_status : ProductStatus
}
type ProductStatus {
id: ID,
order: String,
}
This is how you could design it.这就是你可以设计它的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.