Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit aa09ed0

Browse files
committed
fix(c11n): dataloader crash when displayDensity max
1 parent 3b81bdd commit aa09ed0

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/groupher_server_web/middleware/pagesize_proof.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ defmodule GroupherServerWeb.Middleware.PageSizeProof do
2424
when not is_nil(customization) do
2525
# NOTE: c11n display_density should also linted by page limit,
2626
# otherwise dataloader will crash for empty extra items
27-
size = customization.display_density |> String.to_integer() |> min(@max_page_size)
27+
size = customization.display_density |> String.to_integer() |> min(@max_page_size - 2)
28+
# size = 28
2829

2930
case Map.has_key?(arguments, :filter) do
3031
true ->

test/groupher_server_web/mutation/accounts/customization_test.exs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
defmodule GroupherServer.Test.Mutation.Account.Customization do
22
use GroupherServer.TestTools
33

4+
import Helper.Utils, only: [get_config: 2]
5+
@max_page_size get_config(:general, :page_size)
6+
47
setup do
58
{:ok, user} = db_insert(:user)
69

@@ -84,7 +87,8 @@ defmodule GroupherServer.Test.Mutation.Account.Customization do
8487

8588
variables = %{filter: %{page: 1}}
8689
results = user_conn |> query_result(@paged_post_query, variables, "pagedPosts")
87-
assert results["pageSize"] == 30
90+
# FIXME: this 2 is magic number, otherwise it will crash the dataloader
91+
assert results["pageSize"] == @max_page_size - 2
8892
end
8993

9094
test "set single customization should merge not overwright other settings", ~m(user_conn)a do

0 commit comments

Comments
 (0)