3 python mutation flask graphql
我想查询createThemes到我的graphql。我的graphql查询是:
mutation{
createTheme(name: "qwe"){
theme{
id
}
}
}
Run Code Online (Sandbox Code Playgroud)
所以它出错: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)
Run Code Online (Sandbox Code Playgroud)
小智 8
[解决]我改变了
def mutate(self, name):
Run Code Online (Sandbox Code Playgroud)
对此:
def mutate(self, info, name):
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
533 次 |
| 最近记录: |