import sequelize from '../models';
export default function resolvers() {
const models = sequelize.models;
return {
RootQuery: {
user(root, { id }) {
return models.User.findByPk(id);
},
users(root, args) {
return models.User.findAll({});
},
},
RootMutation: {
createUser (root, { input }) {
return models.User.create(input);
},
updateUser (root, { id, input }) {
return models.User.update(input, {where: { id } });
},
removeUser (root, { id }) {
return models.User.destroy({where: { id } });
},
},
User: {
projects(user) {
return user.getProjects();
}
},
Project: {
tasks(project) {
return project.getTasks();
}
}
};
}