@@ -110,13 +110,13 @@ def find_fragments(filters, options = {})
110110 # @return [Hash{ResourceIdentity => {identity: => ResourceIdentity, cache: cache_field, attributes: => {name => value}, related: {relationship_name: [] }}}]
111111 # the ResourceInstances matching the filters, sorting, and pagination rules along with any request
112112 # additional_field values
113- def find_related_fragments ( source_rids , relationship_name , options = { } )
113+ def find_related_fragments ( source_rids , relationship_name , options = { } , included_key = nil )
114114 relationship = _relationship ( relationship_name )
115115
116116 if relationship . polymorphic? && relationship . foreign_key_on == :self
117117 find_related_polymorphic_fragments ( source_rids , relationship , options )
118118 else
119- find_related_monomorphic_fragments ( source_rids , relationship , options )
119+ find_related_monomorphic_fragments ( source_rids , relationship , included_key , options )
120120 end
121121 end
122122
@@ -162,7 +162,7 @@ def find_records_by_keys(keys, options = {})
162162 records . where ( { _primary_key => keys } )
163163 end
164164
165- def find_related_monomorphic_fragments ( source_rids , relationship , options = { } )
165+ def find_related_monomorphic_fragments ( source_rids , relationship , included_key , options = { } )
166166 source_ids = source_rids . collect { |rid | rid . id }
167167
168168 context = options [ :context ]
@@ -185,7 +185,8 @@ def find_related_monomorphic_fragments(source_rids, relationship, options = {})
185185
186186 # ToDO: Remove count check. Currently pagination isn't working with multiple source_rids (i.e. it only works
187187 # for show relationships, not related includes).
188- if paginator && source_rids . count == 1
188+ # Check included_key to not paginate included resources but ensure that nested resources can be paginated
189+ if paginator && source_rids . count == 1 && !included_key
189190 records = related_klass . apply_pagination ( records , paginator , order_options )
190191 end
191192
0 commit comments