Support a better API for ordering by multiple fields when using @strawberry_django.order
by allowing it to be generated as a list of orderings.
As stated in #677 the way strawberry_django.order
distinguishes "order by name then birthday" vs "order by birthday then name" as follows:
order: {
name: ASC
birthday: ASC
}
vs.
order: {
birthday: ASC
name: ASC
}
This is problematic, because usually object key order is considered to be not relevant. While object property order is now guaranteed in JavaScript and dict order is guaranteed in Python, this is still far from an ideal API, because usually object key order is considered irrelevant. Creating an object/dict with a required key order and then making sure that order is preserved when being serialized out to JSON can be challenging or might even be impossible in some languages, because the implementations might not preserve the order.
The JSON specification also states that (emphasis mine):
An object is an unordered set of name/value pairs.
This is also demonstrated by the hoops that the code needs to jump through to even extract this information from the GraphQL Python implementation.
I propose adding an option to @strawberry_django.order
named multi
. If set to true, the order
parameter would be generated as a list instead, allowing the explicit specification of multiple ordering objects.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too