t
k
Take a look at nilan's answer here: https://www.prisma.io/forum/t/how-to-use-field-resolvers-to-get-aggregates-of-inner-relation-types/2930 (just don't forget to use
extractFragmentReplacements
, see the last comment)
instead of a function, a resolver can be an object with a
fragment
and
resolve
props
t
@kratam thanks for your help! I followed the advice there, but could not make it work. Can you look at following code and tell me what is wrong ? I’m getting
Unknown fragment 'notificationFragment'
export const query: Query = { notifications: { fragment: gql` fragment notificationFragment on Notification { id createdAt params code text type }
Copy code
,
    async resolve(
      _parent,
      { input: { skip = 0, first = 100, visible } },
      ctx,
      info
    ): Promise<Yoga.Notification[]> {
      const userId = getUserId(ctx);
      const user = await ctx.db.query.user(
        { where: { id: userId } },
        gql
{ notifications (first: ${first}, skip: ${skip}) { ...notificationFragment } } ` ); return user.notifications; } } };
I did do, extractFragments and included them in prismaInitialisation
@kratam I now understand the use of fragments. and see how can I use them. Thanks for your help.