In cases where multiple order_by fields are specified, it seems that there is not a way to specify or guarantee order when provided as a query variable.
For example, the following query maintains the order of name first, then id.
query {
companies (
order_by: {
name: ASC
id: ASC
}
) {
...company
}
}
However, if the order_by provided as a query variable, the order cannot be preserved and would end executing as id first, then name.
query {
companies($orderBy: CompanySort) (
order_by: $orderBy
) {
...company
}
}
Is there any way to maintain the order_by order using the variable approach?
Oh, you are right :) This will actually be fixed with version 11. The issue here is that with V10 the variables are kept in a dictionary structure. The default dictionary has no order since it is basically a hashtable.
The literals on the other hands are kept as object literals which have a field order.
With the next version we have unified this, so it should be fixed then.
btw, thank you for filing this issue :) 馃憤
Most helpful comment
Oh, you are right :) This will actually be fixed with version 11. The issue here is that with V10 the variables are kept in a dictionary structure. The default dictionary has no order since it is basically a hashtable.
The literals on the other hands are kept as object literals which have a field order.
With the next version we have unified this, so it should be fixed then.