@@ -35,7 +35,7 @@ class OtherArrayConnection < GraphQL::Pagination::ArrayConnection; end
35
35
end
36
36
37
37
it "returns connections by class, using inherited mappings and local overrides" do
38
- field_defn = OpenStruct . new ( max_page_size : 10 , type : GraphQL ::Types ::Relay ::BaseConnection )
38
+ field_defn = OpenStruct . new ( has_max_page_size? : true , max_page_size : 10 , type : GraphQL ::Types ::Relay ::BaseConnection )
39
39
40
40
set_wrapper = schema . connections . wrap ( field_defn , nil , Set . new ( [ 1 , 2 , 3 ] ) , { } , nil )
41
41
assert_instance_of SetConnection , set_wrapper
@@ -114,12 +114,45 @@ def things2
114
114
115
115
it "lets unrelated NoMethodErrors bubble up" do
116
116
err = assert_raises NoMethodError do
117
- pp ConnectionErrorTestSchema . execute ( "{ things2 { name } }" )
117
+ ConnectionErrorTestSchema . execute ( "{ things2 { name } }" )
118
118
end
119
119
120
120
assert_includes err . message , "undefined method `no_such_method' for <BadThing!>"
121
121
end
122
122
123
+ it "uses a field's `max_page_size: nil` configuration" do
124
+ user_type = Class . new ( GraphQL ::Schema ::Object ) do
125
+ graphql_name 'User'
126
+ field :name , String , null : false
127
+ end
128
+
129
+ query_type = Class . new ( GraphQL ::Schema ::Object ) do
130
+ graphql_name 'Query'
131
+ field :users , user_type . connection_type , null : true , max_page_size : nil
132
+ def users
133
+ [ { name : 'Yoda' } , { name : 'Anakin' } , { name : 'Obi Wan' } ]
134
+ end
135
+ end
136
+
137
+ schema = Class . new ( GraphQL ::Schema ) do
138
+ # This value should be overriden by `max_page_size: nil` in the field definition above
139
+ default_max_page_size 2
140
+ query ( query_type )
141
+ end
142
+
143
+ res = schema . execute ( <<-GRAPHQL ) . to_h
144
+ {
145
+ users {
146
+ nodes {
147
+ name
148
+ }
149
+ }
150
+ }
151
+ GRAPHQL
152
+
153
+ assert_equal [ "Yoda" , "Anakin" , "Obi Wan" ] , res [ 'data' ] [ 'users' ] [ 'nodes' ] . map { |node | node [ 'name' ] }
154
+ end
155
+
123
156
class SingleNewConnectionSchema < GraphQL ::Schema
124
157
class Query < GraphQL ::Schema ::Object
125
158
field :strings , GraphQL ::Types ::String . connection_type , null : false
0 commit comments