首页 文章

关于GraphQL更新的Sequelize不会返回任何内容

提问于
浏览
2

GraphQL使用Sequelize更新返回null .

updatePerson: {
  type: Person,
  args: {
    value: {
      type: UpdatePersonInputType
    },
    where: {
      type: WhereUpdatePersonInputType
    }
  },
  resolve(_, args) {
    return Db.models.persons.update( args.value, {
      where: args.where
    });
  }
},

这里我的请求使用GraphiQL

mutation {
  updatePerson(value: {firstName: "John", lastName: "Doe", email: "johndoe@example.com"}, where: {id: 1}){
    id
    firstName
    lastName
    email
  }
}

这就是结果

{
  "data": {
    "updatePerson": {
      "id": null,
      "firstName": null,
      "lastName": null,
      "email": null
    }
  }
}

也许我使用Sequelize更新会犯错误 . 谁能解释会发生什么?

1 回答

相关问题