-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple, independent, and ordered sortKey and orderBy directions #421
Multiple, independent, and ordered sortKey and orderBy directions #421
Conversation
37a49e5
to
1442a7e
Compare
Hey there, |
fd5556f
to
0054ad2
Compare
This is great! I think I'd deprecate the object syntax in the docs for now, and then in a later release, remove the code for it. |
Do you folks want to land a similar change for |
Yeah, would be good for the recommended APIs to match |
512297c
to
5b24a7b
Compare
Ok. this is updated to change both |
5b24a7b
to
5c22373
Compare
5c22373
to
045a37e
Compare
This sucker is good to go! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
045a37e
to
8797f3d
Compare
Thanks again airhorns! Published in |
The API for
sortKey
right now lets you sort by multiple keys but only in one direction for all of them, which is a bit limiting, especially if you want to let API consumers pass arbitrary sorts or lists of sorts to paginated connections.orderBy
lets you sort by as many keys as you like with independent directions per key -- I thinksortKey
should support the same!This changes the API for
sortKey
from this:to this:
which is more expressive, allowing different orders per key, and keeps the key property of ordering the keys so we know which to sort by first.
orderBy
's object syntax kind of has that implicitly from object iteration order, but this makes it explicit which I think is better and less surprising.The API is backwards compatible, if an object is passed to
sortKey
the old logic that applies the one order to all the keys will still run, and the new format only kicks in if an array is passed. 馃巿I considered using
orderBy
's same style of{[key: string]: Order}
but I think this is more explicit. Relying on object insertion order to power super key API semantics like how things are sorted seems a little haphazard to me, and it means that the SQL output becomes super dependent on how an ordering thunk is implemented, not just it's output. To be honest I'd consider switchingorderBy
to be consistent and use the same explicitly ordered array of key/order pairs. An array of strings would also be good to support things like #321 and #313. If #418 means a big breaking change, it might be a good time to swap in that behaviour. Again, if an array were used, I think it'd be possible to make the API change backwards compatible way so people migrating to 3.0 didn't have to change their code just to make my API design OCD satisfied, but for new people integrating join-monster things would be that much better.