2
mutation{
createPayment(p_obj={"bob": 80, "job": 100}){
     <fields here>
     }
}

What I could find was to accept a list of objects as input like:

[ {username: "bob", "amount": 80}, {username: "job", "amount": 100} ]
Noobie1234
  • 31
  • 2
  • possible duplicate of https://stackoverflow.com/questions/51224477/django-graphene-passing-json-or-dict-data-as-input-for-mutation/51269035#51269035 – Mark Chackerian Jan 20 '20 at 01:16

1 Answers1

4

You can do something like this -

class PaymentInputType(graphene.InputObjectType):
      username = graphene.String()
      amount = graphene.Int()

And use the InputType inside your mutation as following.

class CreatePayment(graphene.Mutation):
    class Arguments:
       input = PaymentInputType(required=True)

    ok = graphene.Boolean()

    @staticmethod
    def mutate(root, info, input):
        # save the changes here 
        return CreatePayment(ok=True)
Ijharul Islam
  • 1,429
  • 11
  • 13