File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ def calculate_sliced_nodes_parameters
117117 return
118118 else
119119 next_offset = relation_offset ( items ) || 0
120+ relation_limit = relation_limit ( items )
121+
120122 if after_offset
121123 next_offset += after_offset
122124 end
Original file line number Diff line number Diff line change @@ -27,14 +27,16 @@ def total_count
2727 total_count_connection_class : RelationConnectionWithTotalCount ,
2828 get_items : -> {
2929 if Food . respond_to? ( :scoped )
30- Food . scoped # Rails 3-friendly version of .all
30+ Food . scoped . limit ( limit ) # Rails 3-friendly version of .all
3131 else
32- Food . all
32+ Food . all . limit ( limit )
3333 end
3434 }
3535 )
3636 }
3737
38+ let ( :limit ) { nil }
39+
3840 include ConnectionAssertions
3941
4042 it "maintains an application-provided offset" do
@@ -62,6 +64,33 @@ def total_count
6264 assert_equal [ "Cucumber" , "Dill" ] , results [ "data" ] [ "offsetItems" ] [ "nodes" ] . map { |n | n [ "name" ] }
6365 end
6466
67+ describe 'with application-provided limit, which is smaller than the max_page_size' do
68+ let ( :limit ) { 1 }
69+
70+ it "maintains an application-provided limit" do
71+ results = schema . execute ( "{
72+ limitedItems {
73+ nodes { name }
74+ }
75+ }" )
76+ assert_equal [ "Avocado" ] , results [ "data" ] [ "limitedItems" ] [ "nodes" ] . map { |n | n [ "name" ] }
77+ end
78+ end
79+
80+ describe 'with application-provided limit, which is larger than the max_page_size' do
81+ let ( :limit ) { 3 }
82+
83+ it "applies a field-level max-page-size configuration" do
84+ results = schema . execute ( "{
85+ limitedItems {
86+ nodes { name }
87+ }
88+ }" )
89+ assert_equal [ "Avocado" , "Beet" ] , results [ "data" ] [ "limitedItems" ] [ "nodes" ] . map { |n | n [ "name" ] }
90+ end
91+ end
92+
93+
6594 it "doesn't run pageInfo queries when not necessary" do
6695 results = nil
6796 log = with_active_record_log do
You can’t perform that action at this time.
0 commit comments