I am trying to implement mutations in GraphQL. I am using GraphQL Play Ground Ui for query.
Here is my mutation :
mutation{
createProduct (data :{
product: "abc",
product_status : {
"1" : {
order : "done"
}
}
Here is my 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. How can i resolve this. I need to store this type of object in My database.Can someone help me to this.
GraphQL supports strict data typing. 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. I know strings and types but not JSON. You coudld have a object like:
type Product {
product : String,
product_status : ProductStatus
}
type ProductStatus {
id: ID,
order: String,
}
This is how you could design it.