Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: nested sorting #307

Merged
merged 3 commits into from
Mar 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions website/pages/en/querying/graphql-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
}
```

saihaj marked this conversation as resolved.
Show resolved Hide resolved
> 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.
Expand Down