harrisrobin
01/24/2018, 7:42 PMbradrich
01/24/2018, 8:53 PMharrisrobin
01/24/2018, 9:10 PMharrisrobin
01/24/2018, 9:10 PMharrisrobin
01/24/2018, 9:10 PMharrisrobin
01/24/2018, 9:11 PMbradrich
01/24/2018, 9:13 PMConnection
schemas that are added, have read through the docs here: https://www.prismagraphql.com/docs/reference/prisma-api/queries-ahwee4zaey, and can see that they are interested in adding this stuff here: https://github.com/graphcool/graphcool-framework/issues/416, but there are no current work-arounds that I have seen that can be accomplished without a custom Query.harrisrobin
01/24/2018, 9:14 PMharrisrobin
01/24/2018, 9:15 PMharrisrobin
01/24/2018, 9:15 PMharrisrobin
01/24/2018, 9:15 PMavgRating: {
fragment: `fragment AvgRating on Place { id }`,
resolve: async ({ id }, args, ctx: Context, info) => {
const place = await ctx.db.query.place(
{ where: { id } },
`{ reviews { stars } }`,
)
const reviews = place.reviews
const avgRating = reviews.reduce(
(
prevValue: number,
currValue: Review,
currIndex: number,
reviews: Review[],
): number => {
return prevValue + currValue.stars / reviews.length
},
0,
)
return avgRating
},
},
harrisrobin
01/24/2018, 9:17 PMharrisrobin
01/24/2018, 9:17 PMbradrich
01/24/2018, 9:19 PMharrisrobin
01/24/2018, 9:20 PMharrisrobin
01/24/2018, 9:20 PMharrisrobin
01/24/2018, 9:20 PMharrisrobin
01/24/2018, 9:20 PMbradrich
01/24/2018, 9:57 PMharrisrobin
01/24/2018, 10:36 PMharrisrobin
01/24/2018, 10:37 PMharrisrobin
01/24/2018, 10:37 PMharrisrobin
01/24/2018, 10:37 PMharrisrobin
01/24/2018, 10:37 PMharrisrobin
01/24/2018, 10:37 PM