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

我能找到的是接受一个对象列表作为输入,例如:

[ {username: "bob", "amount": 80}, {username: "job", "amount": 100} ]
4

1 回答 1

4

你可以做这样的事情 -

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

并在您的突变中使用 InputType,如下所示。

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)
于 2020-01-19T01:36:00.820 回答