hasura / hasura/graphql-engine
Sorting multiple fields in Hasura Console should be done in array
- Dominant language
- TypeScript
- Stars
- 32.1k
- Forks
- 3k
- PR merge metrics
- PR metrics pending
Description
### Version Information
Server Version: 2.1.0.beta.2
### Environment
OSS
### What is the expected behaviour?
Sorting multiple fields should be done in an array, as of Hasura version 2.0.0 otherwise key ordering is not preserved.
https://hasura.io/docs/latest/graphql/core/guides/upgrade-hasura-v2.html
> The order_by operator accepts an array of objects as input to allow ordering by multiple fields in a given order, i.e. [{field1: sortOrder}, {field2: sortOrder}] but it is also accepts a single object with multiple keys as an input, i.e. {field1: sortOrder, field2: sortOrder}. In earlier versions, Hasura’s query parsing logic used to maintain the order of keys in the input object and hence the appropriate order by clauses with the fields in the right order were generated .
When selecting multiple fields in Hasura Console the ordering is still done in an object instead of an array.
### Keywords
Hasura Console
### What is the current behaviour?
Selecting fields for ordering results in this query
```graphql
query MyQuery {
MyTable(order_by: {field1: asc, field2: asc, field3: asc})
}
```
**Expected behaviour**
```graphql
query MyQuery {
MyTable(order_by: [{field1: asc}, {field2: asc}, {field3: asc}])
}
```
### How to reproduce the issue?
Select multiple fields for sorting.
Contributor guide
Research direction
Start by reproducing the issue in Hasura Console by selecting multiple fields for sorting and inspect the generated GraphQL query. Update the sorting flow so the order_by value uses one object per field in an array, then verify the generated query preserves the selected order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100