问题
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