GraphQL Ordering Support
NetBox version
v4.3.6
Feature type
New functionality
Proposed functionality
With the implementation of pagination in #16224, I thought that might have also introduced ordering, but that does not seem to be the case. Therefore, I propose ordering as an additional argument alongside filters and pagination when accessing non-scalar types. It would work the same as the ordering argument in the REST API, but should probably be turned into an array of strings instead of a single comma-separated string.
Use case
I need to pull nested data from NetBox and using the REST API does not allow that without N+1 queries. Initially, I wrote an export template to solve this problem, but as the output format needs to be JSON, that started becoming tedious, so I decided to explore the possibility of using GraphQL instead. It ended up being fairly straightforward to get the shape of the data I needed, but I was disappointed to find that ordering was not possible. In my case, I am grabbing the members of a virtual chassis and I need them in order of vc_position, not name, as they seem to be by default. My hope was that I could unmarshal the JSON response directly without additional processing.
Database changes
None
External dependencies
None
Strawberry does have ordering support https://strawberry.rocks/docs/django/guide/ordering this would be a fairly substantial change as ordering enum and input would need to be be defined for all model types.
I think we have a fairly good understanding of what this entails, however it's still to be determined whether this could effect a breaking change.