-
Notifications
You must be signed in to change notification settings - Fork 223
Description
I'd love to be able to do something similar to where
functions, where I can construct my own complex orderBy
.
The problem is that right now if I want to do something as simple as:
ORDER BY -`table`.`field` DESC
I can't see a way to do this with JM without explicitly defining the field on the schema, and using alwaysFetch
.
In the app I'm working on (we're converting an old code base to GraphQL), we default to natural ordering, but also allow users to explicitly order items, which means the sort field is usually null, unless it's explicitly set to a number (with 0 being the highest sort priority).
In MySQL, null comes before values in an ASC sort, and goes after values in a DESC sort.
So to achieve the desired functionality I need a DESC sort on the field, but this will sort with higher numbers being a higher sort priority.
This can be fixed by the above order by, with a -
in front of it. But as stated this is unsupported in JM.