mutate()为参数“名称”获得了多个值

时间:2018-12-08 12:50:32

标签: python flask graphql mutation

我想查询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)

1 个答案:

答案 0 :(得分:4)

[已解决] 我改变了

def mutate(self, name):

对此:

def mutate(self, info, name):