gpt4 book ai didi

python - mutate()为参数 'name'获取了多个值

转载 作者:行者123 更新时间:2023-12-03 15:49:10 29 4
gpt4 key购买 nike

我想查询createThemes到我的graphql。
我的graphql查询是:

mutation{
createTheme(name: "qwe"){
theme{
id
}
}
}

所以它报错: mutate() got multiple values for argument 'name'你能解决并解释为什么它打印这种错误。

我的代码如下:
from models import Theme as ThemeModel, Topic as TopicModel, Article as ArticleModel

...

class CreateTheme(graphene.Mutation):
class Arguments:
id = graphene.Int()
name = graphene.String()

theme = graphene.Field(lambda: Theme)

def mutate(self, name):
theme = ThemeModel(name = name)
theme.insert()

return CreateTheme(theme = theme)

...

class Mutation(graphene.ObjectType):
create_theme = CreateTheme.Field()

...

schema = graphene.Schema(query=Query, mutation = Mutation)

最佳答案

[解决了]
我变了

def mutate(self, name):

对此:
def mutate(self, info, name):

关于python - mutate()为参数 'name'获取了多个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53682698/

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