you will have to do this yourself via a custom res...
# prisma-whats-new
h
you will have to do this yourself via a custom resolver
b
I see. So, I would need to complete a secondary request to retrieve that information? One of the reasons for switching to GraphQL is the idea of only making one request versus a Rest API with several. Please school me if I am wrong.
h
I'm not sure myself, i don't think doing a custom resolver adds another request. I'd love to know more about the overhead of htat myself but it's been hard to get an answer.
maybe @nilan can chime in at some point about this
?
I have an issue open as im having some issues with the performance of custom resolvers https://github.com/graphcool/graphql-server-example/issues/85
b
I can see the various
Connection
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.
h
yeah that's my finding too, which is why i am suggestion a custom resolver
for example, i have an app that needs avgRatings
i have sometihng like this:
Copy code
avgRating: {
    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
    },
},
but i still don't understand the overhead of a custom resolver
and how it impacts the query's performance
b
I can see in your issue that the spike was pretty dramatic.
h
yeah.. it's worrying me because i don't understand the casue
cause*
im hoping it's just because Prisma db is hosted on a shared cluster
but it doesn't make sense
b
When you were building a list of places, how did you call that custom resolver? I must not understand its implementation.
h
@bradrich I did nothing special that is not done in that example repo.
if you remove custom resolver
query takes 14u
you add one
7 seconds
😅