Has anyone managed to paginate nested subfields wi...
# orm-help
m
Has anyone managed to paginate nested subfields with Prisma Client ?
h
Like this?
Copy code
return await context.client.discussion({ id: dId })
    .messages({
        orderBy: 'createdAt_DESC',
        first: count,
        after: cursor,
    });
m
hmm… I have a similar set up but it’s not working for me.
Lemme share my resolvers
```
Copy code
getUserLogs: async (_, {first, skip}, ctx) => {
      const logs = await ctx.prisma.user({id: getUserId(ctx)}).logs({
        first, skip
      });
Copy code
User: {
    logs(root, args, context){
      return context.prisma.user({id:root.id}).logs({orderBy: "created_at_DESC"})
    },
but suppose that one doesn’t matter since it should never be hit
the problem I’m experiencing is that all of the logs are coming back. even if I ask for one.
oddly enough orderBy works fine but first, skip has no effect
Copy code
type User {
  id: ID! @unique
  username: String! @unique
  email: String! @unique
  password: String!
  logs: [Log!]! @relation(name:"UserLogs", onDelete: CASCADE)
  sets: [Set!]! @relation(name:"UserSets", onDelete: CASCADE)
}

type Log {
  id: ID! @unique
  created_at: DateTime!
  sets: [Set!]! @relation(name: "SetsOnLog" onDelete: CASCADE)
  user: User! @relation(name:"UserLogs", onDelete: SET_NULL)
}
data model
any chance you are using postgres? I have been trying to figure this out for days to no avail
think I figured it out actually. adding a space after name in @relation(name: “”) seems to have fixed the issue. must have been causing some ambiguity i guess.
jk not working
n
I've seen your forum post and will try to get back there soon 🙂 https://www.prisma.io/forum/t/how-to-paginate-nested-fields-in-prisma-client/4435?u=nilan