Noo*_*234 2 python-3.x graphql graphene-python graphene-django
mutation{
createPayment(p_obj={"bob": 80, "job": 100}){
<fields here>
}
}
Run Code Online (Sandbox Code Playgroud)
我能找到的是接受对象列表作为输入,例如:
[ {username: "bob", "amount": 80}, {username: "job", "amount": 100} ]
Run Code Online (Sandbox Code Playgroud)
小智 5
你可以做这样的事情 -
class PaymentInputType(graphene.InputObjectType):
username = graphene.String()
amount = graphene.Int()
Run Code Online (Sandbox Code Playgroud)
并在突变中使用 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)
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2054 次 |
最近记录: |