Skip to content

Commit 28c9f1f

Browse files
authored
docs: nested sorting (#307)
* docs: nested sorting * Address feedback * clarify
1 parent c770893 commit 28c9f1f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

website/pages/en/querying/graphql-api.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ When querying a collection, the `orderBy` parameter may be used to sort by a spe
4949
}
5050
```
5151

52+
#### Example for nested entity sorting
53+
54+
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.
55+
56+
In the following example, we sort the tokens by the name of their owner:
57+
58+
```graphql
59+
{
60+
tokens(orderBy: owner__name, orderDirection: asc) {
61+
id
62+
owner {
63+
name
64+
}
65+
}
66+
}
67+
```
68+
69+
> 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.
70+
5271
### Pagination
5372

5473
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.

0 commit comments

Comments
 (0)