From bd0eab5e6d020e3e46fa46ba09b7709329c0886f Mon Sep 17 00:00:00 2001 From: Kyrch Date: Sat, 26 Jul 2025 19:38:22 -0300 Subject: [PATCH] docs(graphql): sorting documentation (#115) --- docs/guide/graphql/sorting/index.md | 58 ++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/docs/guide/graphql/sorting/index.md b/docs/guide/graphql/sorting/index.md index 79684fb..0c92023 100644 --- a/docs/guide/graphql/sorting/index.md +++ b/docs/guide/graphql/sorting/index.md @@ -6,6 +6,60 @@ title: Sorting --- -// TODO +Most queries provide a unique `sort` argument to manage resource sorting. +This argument accepts a list of `{type}SortableColumns` enum cases. -// Note: Waiting API refactor. \ No newline at end of file +To sort in ascending order, the field name is enough. + +To sort in descending order, append `_DESC` to the field name. + +## Query + +```graphql +{ + animes(sort: NAME) { # Sorting in ascending direction. + data { + name + } + } + + animes(sort: NAME_DESC) { # Sorting in descending direction. + data { + name + } + } +} +``` + +## Nested Sorting + +It is possible to sort the relationships of the parent type. + +```graphql +{ + animes { + data { + resources(sort: EXTERNAL_ID) { + nodes { + externalId + } + } + } + } +} +``` + +## Multiple Sorting + +By providing a list of enum cases, the sort will be applied in the order of the values provided by the client. + +```graphql +{ + animes(sort: [YEAR_DESC, SEASON]) { + data { + year + season + } + } +} +``` \ No newline at end of file