Joellao
10/09/2018, 6:43 PMgetUserRateAverage(parent, args, ctx, info) {
let rates = ctx.db.query.rates({}, info);
let sum = 0;
for (let i = 0; i < rates.length; i++) {
sum += rates[i];
}
return rates.length != null ? sum / rates.length : 0;
}, but don't know if this is even legit hahahaha, really new with GraphQL and Prisma. Let me know!nilan
10/10/2018, 3:37 PMJoellao
10/10/2018, 6:51 PMnilan
10/10/2018, 6:52 PMinfo I guessJoellao
10/10/2018, 7:04 PMquery{
getTopics{
title
}
}, is it possible to attach to it the topicAverage for example? Right now I'm calling it with the snippet passing a topicID and calculating all the rates but If I could do it with one request instead of fetching all the topics and after that fetching for each post the average, that would be super useful. Accessing it like this maybe getTopics{
title,
rateAVG
}