diff --git a/website/pages/en/querying/graphql-api.mdx b/website/pages/en/querying/graphql-api.mdx index 986d7bf15c35..8e12eafcaca7 100644 --- a/website/pages/en/querying/graphql-api.mdx +++ b/website/pages/en/querying/graphql-api.mdx @@ -49,6 +49,25 @@ When querying a collection, the `orderBy` parameter may be used to sort by a spe } ``` +#### Example for nested entity sorting + +As of Graph Node [`v0.30.0`](https://github.com/graphprotocol/graph-node/releases/tag/v0.30.0) entities can be sorted on the basis of nested entities. + +In the following example, we sort the tokens by the name of their owner: + +```graphql +{ + tokens(orderBy: owner__name, orderDirection: asc) { + id + owner { + name + } + } +} +``` + +> Currently you can sort by one-level deep `String` or `ID` types on `@entity` and `@derivedFrom` fields. Unfortunately, [sorting by interfaces on one level-deep entities](https://github.com/graphprotocol/graph-node/pull/4058), sorting by fields which are arrays and nested entities is not yet supported. + ### 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.