Files
talk/graph/resolvers/asset.js
T
2017-02-06 12:54:55 -07:00

30 lines
751 B
JavaScript

const Asset = {
recentComments({id}, _, {loaders: {Comments}}) {
return Comments.genRecentComments.load(id);
},
comments({id}, {sort, limit}, {loaders: {Comments}}) {
return Comments.getByQuery({
asset_id: id,
sort,
limit,
parent_id: null
});
},
commentCount({id}, _, {loaders: {Comments}}) {
return Comments.countByAssetID.load(id);
},
settings({settings = null}, _, {loaders: {Settings}}) {
return Settings.load()
.then((globalSettings) => {
if (settings) {
settings = Object.assign({}, globalSettings.toObject(), settings);
} else {
settings = globalSettings.toObject();
}
return settings;
});
}
};
module.exports = Asset;