【发布时间】:2019-05-09 23:56:08
【问题描述】:
我想向我的 graphql 查询 createThemes。 我的 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)
【问题讨论】:
标签: python flask graphql mutation