What's the best way to sort an array of nodes? For...
# prisma-whats-new
e
What's the best way to sort an array of nodes? For example, the cards into the Table type:
Copy code
type Table {
  id: ID! @unique
  cards: [Card!]!
}

type Card {
  id: ID! @unique
}
The idea is that the user can drag & drop the Card in the order they want. For clarity, I ended up writing a post in the forum: https://www.graph.cool/forum/t/ordering-nodes-with-prisma/2523
👍 1
posted to the forum as well @Emi
e
I haven't found any info about this and seems to be a bit tricky. Any recommendation on how to do sorting mutations with Prisma?
h
Add field
position
and then you can have
cards(orderBy: position_DESC)
e
@huv1k What I’m a bit confused is about how to deal with the mutations for creating/updating and deleting this sorted nodes. The idea is that the user can drag & drop the Card in the order they want.
h
updateCard(id, position)
?
e
Yes, sounds good. However, how would you write the implementation of this resolver? I was thinking in a batch mutation but didn't succeed, as you can see here: https://www.graph.cool/forum/t/prisma-increase-current-field-value-in-a-batch-mutation/2529