From bce89e985c40764fc33008989becc01208e18a28 Mon Sep 17 00:00:00 2001 From: Barnabas Jovanovics Date: Mon, 28 Aug 2023 16:42:39 +0200 Subject: [PATCH] feat: add more sort order values (#91) --- lib/api/api.ex | 28 ++++++++++++++++++++++++++++ test/paginate_test.exs | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/lib/api/api.ex b/lib/api/api.ex index 4c6f9299..384ffe16 100644 --- a/lib/api/api.ex +++ b/lib/api/api.ex @@ -196,12 +196,40 @@ defmodule AshGraphql.Api do name: "DESC", value: :desc }, + %Absinthe.Blueprint.Schema.EnumValueDefinition{ + module: schema, + identifier: :desc_nils_first, + __reference__: AshGraphql.Resource.ref(env), + name: "DESC_NULLS_FIRST", + value: :des_nils_first + }, + %Absinthe.Blueprint.Schema.EnumValueDefinition{ + module: schema, + identifier: :desc_nils_last, + __reference__: AshGraphql.Resource.ref(env), + name: "DESC_NULLS_LAST", + value: :desc_nils_last + }, %Absinthe.Blueprint.Schema.EnumValueDefinition{ module: schema, identifier: :asc, __reference__: AshGraphql.Resource.ref(env), name: "ASC", value: :asc + }, + %Absinthe.Blueprint.Schema.EnumValueDefinition{ + module: schema, + identifier: :asc_nils_first, + __reference__: AshGraphql.Resource.ref(env), + name: "ASC_NULLS_FIRST", + value: :asc_nils_first + }, + %Absinthe.Blueprint.Schema.EnumValueDefinition{ + module: schema, + identifier: :asc_nils_last, + __reference__: AshGraphql.Resource.ref(env), + name: "ASC_NULLS_LAST", + value: :asc_nils_last } ], identifier: :sort_order, diff --git a/test/paginate_test.exs b/test/paginate_test.exs index 07b27dc9..56a41de4 100644 --- a/test/paginate_test.exs +++ b/test/paginate_test.exs @@ -33,7 +33,7 @@ defmodule AshGraphql.PaginateTest do test "default_limit records are fetched" do doc = """ query KeysetPaginatedPosts { - keysetPaginatedPosts(sort: [{field: TEXT}]) { + keysetPaginatedPosts(sort: [{field: TEXT, order: ASC_NULLS_LAST}]) { count startKeyset endKeyset