Skip to main content

Module order_by

Module order_by 

Source
Expand description

Ordering and distinct input types.

Hasura orders with order_by: [<table>_order_by!] where each entry maps a column to a direction drawn from one shared enum:

author(order_by: [{name: asc_nulls_last}, {id: desc}]) { id }

A list rather than a single object, because ordering is ordered: {name: asc, id: desc} is one object whose two keys have no defined precedence, and the client that wrote it meant name first.

The direction enum carries null placement, which the previous orderBy: ["name.asc"] strings could not express at all. In PostgreSQL nulls sort last ascending and first descending, so asc and asc_nulls_last mean the same thing and asc_nulls_first does not – which is exactly the case a client reaches for the enum to say.

distinct_on takes columns from a generated enum rather than strings, for the same reason the boolean expressions do: an unknown column should be refused by the client, not by the database.

Constants§

DIRECTION_ENUM
The name of the shared direction enum.

Functions§

aggregate_order_by_type_name
The name of the input for ordering a row by an aggregate of its children.
build_inputs
The ordering input and column enum for every table.
direction_enum
The shared direction enum.
direction_sql
The SQL for a direction, or None if it is not one.
function_order_by_type_name
The name of the input for ordering by one aggregate function’s results.
order_by_type_name
The name of a table’s ordering input.
select_column_type_name
The name of a table’s column enum.