Hi, there! :wave: Can anybody helps me to understa...
# prisma-client
t
Hi, there! 👋 Can anybody helps me to understand how sort in includes works So, I have resolver with a
prisma-client
(
v2.23.0
) call. Here I'm trying to sort included issues. But nothing happens. Any kind of sort doesn't have effect.
Copy code
@Query(() => Queue, { nullable: true })
    async queueByKey(@Arg('key', () => String) key: string, @Ctx() ctx: Context) {
        return ctx.prisma.queue.findUnique({
            where: { key },
            include: {
                issues: {
                    orderBy: {
                        createdAt: 'desc',
                    },
                },
            },
        });
    }
Thanks for the any suggestion! 🙏
🙏 1
r
@Tony Vi 👋 Sort in include only works inside the relations. So each
queue
has
issues
and the
issues
will be ordered by the
createdAt
field. This will have no effect on the
queue
data, just the data in the relation.
t
So each 
queue
 has 
issues
 and the 
issues
 will be ordered by the 
createdAt
 field.
Exactly what I want!) But it doesn't work
r
It should, could you share a reproduction?
t
No idea how to do that, you need to have db connection...
r
Works fine for me. I added some seed data to the models and here’s the output: I would suggest trying on the latest version of
@prisma/client
and
prisma
and also check if the logs you’re getting are correct or not.
t
Wow! Latest is 2.25.0?
r
t
Ok! Thank you so much. I'm trying to update
💯 1