Sequelize on GraphQL update not return anything

烂漫一生 提交于 2019-12-11 00:14:25

问题


GraphQL return null using Sequelize update.

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

Here my request using GraphiQL

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

and this the result

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

Maybe I make mistakes using Sequelize update. Can anyone explain what happens?


回答1:


My bad, I'm using MySQL, Sequelize just support PostgreSQL if you need return affectedRows, but if you use MySQL you just can only return affectedCount.

http://docs.sequelizejs.com/en/latest/api/model/#updatevalues-options-promisearrayaffectedcount-affectedrows



来源:https://stackoverflow.com/questions/41093459/sequelize-on-graphql-update-not-return-anything

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!