diff --git a/website/src/docs/hotchocolate/fetching-data/sorting.md b/website/src/docs/hotchocolate/fetching-data/sorting.md index 712bfa3de85..af3a73c4baf 100644 --- a/website/src/docs/hotchocolate/fetching-data/sorting.md +++ b/website/src/docs/hotchocolate/fetching-data/sorting.md @@ -113,8 +113,47 @@ public class Query -> ⚠️ **Note:** If you use more than one middleware, keep in mind that **ORDER MATTERS**. The correct order is UsePaging > UseProjections > UseFiltering > UseSorting - +> ⚠️ **Note:** If you use more than one middleware, keep in mind that **ORDER MATTERS**. The correct order is UsePaging > UseProjections > UseFiltering > UseSorting + +The type can be sorted using the `order` field in the query: + +```graphql +query { + users(order: [{name: ASC}]) { + name + address { + street + } + } +} +``` + +Properties of nested objects can be sorted as well: + +```graphql +query { + users(order: [{address: {street: ASC}}]) { + name + address { + street + } + } +} +``` + +Note that it is possible to sort on a field and then by another field: + +```graphql +query { + users(order: [{name: ASC}, {address: {street: DESC}}]) { + name + address { + street + } + } +} +``` + # Customization Under the hood, sorting is based on top of normal Hot Chocolate input types. You can easily customize them with a very familiar fluent interface. The sorting input types follow the same `descriptor` scheme as you are used to from the normal input types. Just extend the base class `SortInputType` and override the descriptor method.