这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/graphql/manual/api-reference/query.rst
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,18 @@ OrderByEnum

#the order_by enum type
enum order_by {
#in the ascending order
#in the ascending order, nulls last
asc
#in the descending order
desc
#in the ascending order, nulls last
asc_nulls_last
#in the ascending order, nulls first
asc_nulls_first
#in the descending order, nulls first
desc
#in the descending order, nulls first
desc_nulls_first
#in the descending order, nulls last
desc_nulls_last
}


Expand Down
15 changes: 10 additions & 5 deletions docs/graphql/manual/queries/sorting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ objects too.
The sort order (ascending vs. descending) is set by specifying ``asc`` or ``desc``
enum value for the column name in the ``order_by`` input object e.g. ``{name: desc}``.

By default, ``null`` values are returned at the end of the results. ``null`` values can be fetched first by specifying
``asc_nulls_first`` (ascending) and ``desc_nulls_first`` (descending) enum value e.g. ``{name: desc_nulls_first}``.
By default, for ascending ordering ``null`` values are returned at the end of the results and for descending ordering ``null``
values are returned at the start of the results. ``null`` values can be fetched first on ascending ordering by specifying
``asc_nulls_first`` and last on descending ordering by specifying ``desc_nulls_last`` enum value e.g. ``{name: desc_nulls_last}``.

The ``order_by`` argument takes an array of objects to allow sorting by multiple columns.

Expand All @@ -29,14 +30,18 @@ The ``order_by`` argument takes an array of objects to allow sorting by multiple

#the order_by enum type
enum order_by {
#in the ascending order
#in the ascending order, nulls last
asc
#in the descending order
desc
#in the ascending order, nulls last
asc_nulls_last
#in the ascending order, nulls first
asc_nulls_first
#in the descending order, nulls first
desc
#in the descending order, nulls first
desc_nulls_first
#in the descending order, nulls last
desc_nulls_last
}

.. Note::
Expand Down
4 changes: 3 additions & 1 deletion server/src-lib/Hasura/GraphQL/Resolve/Select.hs
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ parseOrderByEnum
-> m (S.OrderType, S.NullsOrder)
parseOrderByEnum = \case
G.EnumValue "asc" -> return (S.OTAsc, S.NLast)
G.EnumValue "desc" -> return (S.OTDesc, S.NLast)
G.EnumValue "asc_nulls_last" -> return (S.OTAsc, S.NLast)
G.EnumValue "asc_nulls_first" -> return (S.OTAsc, S.NFirst)
G.EnumValue "desc" -> return (S.OTDesc, S.NFirst)
G.EnumValue "desc_nulls_first" -> return (S.OTDesc, S.NFirst)
G.EnumValue "desc_nulls_last" -> return (S.OTDesc, S.NLast)
G.EnumValue v -> throw500 $
"enum value " <> showName v <> " not found in type order_by"

Expand Down
12 changes: 9 additions & 3 deletions server/src-lib/Hasura/GraphQL/Schema.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,14 +1063,20 @@ ordByEnumTy =
[ ( "asc"
, "in the ascending order, nulls last"
),
( "desc"
, "in the descending order, nulls last"
( "asc_nulls_last"
, "in the ascending order, nulls last"
),
( "asc_nulls_first"
, "in the ascending order, nulls first"
),
( "desc"
, "in the descending order, nulls first"
),
( "desc_nulls_first"
, "in the ascending order, nulls first"
, "in the descending order, nulls first"
),
( "desc_nulls_last"
, "in the descending order, nulls last"
)
]

Expand Down