graphql_relay icon indicating copy to clipboard operation
graphql_relay copied to clipboard

Introspect Ecto Connection order field and direction from query

Open seanabrahams opened this issue 7 years ago • 0 comments

We recently updated the API for Ecto Connections to accept arguments for sorting the connection by adding ordered_by and ordered_by_direction arguments. This works if you want to sort by the Connection's underlying table, but not if you want to sort by a joined table.

Thinking on this it became clear that we can simply look to see if the passed in Ecto query has an order_by clause from which we can then derive the sort field and direction. We don't need separate ordered_by and ordered_by_direction arguments. Just introspect the query.

seanabrahams avatar Jul 19 '16 01:07 seanabrahams