From 86605a18d3976392ce028a2d80c42df9c2d23115 Mon Sep 17 00:00:00 2001 From: Saihajpreet Singh Date: Thu, 9 Mar 2023 14:16:25 -0500 Subject: [PATCH] docs: nested sorting --- website/pages/en/querying/graphql-api.mdx | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/website/pages/en/querying/graphql-api.mdx b/website/pages/en/querying/graphql-api.mdx index 986d7bf15c35..d24092916595 100644 --- a/website/pages/en/querying/graphql-api.mdx +++ b/website/pages/en/querying/graphql-api.mdx @@ -49,6 +49,23 @@ When querying a collection, the `orderBy` parameter may be used to sort by a spe } ``` +#### Example for nested entity sorting + +Sorting on the basis of nested entities is useful if you are looking to sort entities based on child fields. + +In the following example, we sort the tokens by the name of their owner: + +```graphql +{ + tokens(orderBy: owner__name, orderDirection: asc) { + id + owner { + name + } + } +} +``` + ### Pagination When querying a collection, the `first` parameter can be used to paginate from the beginning of the collection. It is worth noting that the default sort order is by ID in ascending alphanumeric order, not by creation time.