-
Notifications
You must be signed in to change notification settings - Fork 54
Sort query results
Igor Dianov edited this page May 29, 2024
·
1 revision
Sorting is supported on any field. Simply pass in an 'orderBy' argument with the value of ASC or DESC. Here's an example of sorting by name for Human objects. The default sort order can be specified using GraphQLDefaultSort annotation on entity field. If sort order is not specified and there is no field with default sort order provided, we will use field annotated with @Id to avoid paging confusions.
{
Books {
select {
id
title(orderBy:DESC)
tags
}
}
}
{
"data": {
"Books": {
"select": [
{
"id": 2,
"title": "War and Peace"
},
{
"id": 7,
"title": "Three Sisters"
},
{
"id": 6,
"title": "The Seagull"
},
{
"id": 5,
"title": "The Cherry Orchard"
},
{
"id": 3,
"title": "Anna Karenina"
}
]
}
}
}