Skip to content

Ordering

We can sort query results using the orderBy argument that is added when extending the schema with fastGQL. The value of the sort argument should be an array containing the name of fields to sort the result by.

Simple Sort

query {
posts(orderBy: {name: ASC}) {
name
}
}

Multiple fields

query {
posts(orderBy: [{name: ASC}, {id: DESC}]) {
name
}
}

Sorting Nested Queries

query {
posts(orderBy: {name: DESC}) {
name
categories(orderBy: {name: ASC_NULL_FIRST}) {
name
}
}
}