I have the following situation: I have a User, each user has a Inventory. I'm struggling to declare the user's inventory in the Mutation "CreateUser". Here is the following mutation for creating the user:
mutation Create{
addUser(UserData:{name:"Shibunika",age:21}
}
I'm trying to declare the user's inventory in this mutation, I expected something like
mutation Create{
addUser(UserData:{name:"Shibunika",age:21,inventory:{'item1':45,'item2':25}
}s
these number are the quantity of each item. How do I define these inputs in graphene? Would you gently show me a schema for this?
You can create a custom object type to represent a key value pair, and then have a list of these in your user schema.
The syntax is a bit clunky but workable:
mutation { addUser(name:"Shibunika", age:21, inventory:[ {name: "item1", intValue: 45}, {name: "item2", intValue:25}]){ok}