gpt4 book ai didi

python-3.x - 我如何接受字典/对象作为 Graphite 烯(GraphQL)突变的输入?

转载 作者:行者123 更新时间:2023-12-03 08:49:36 26 4
gpt4 key购买 nike

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

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

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

最佳答案

你可以做这样的事情 -

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)

关于python-3.x - 我如何接受字典/对象作为 Graphite 烯(GraphQL)突变的输入?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59771469/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com