@@ -238,7 +238,16 @@ def resolve_critical_files(commit: Commit, info, **kwargs) -> List[CriticalFile]
238238@commit_bindable .field ("pathContents" )
239239@convert_kwargs_to_snake_case
240240@sync_to_async
241- def resolve_path_contents (commit : Commit , info , path : str = None , filters = None ):
241+ def resolve_path_contents (
242+ commit : Commit ,
243+ info ,
244+ path : str = None ,
245+ filters = None ,
246+ first : int = None ,
247+ after : str = None ,
248+ last : int = None ,
249+ before : str = None ,
250+ ):
242251 """
243252 The file directory tree is a list of all the files and directories
244253 extracted from the commit report of the latest, head commit.
@@ -314,7 +323,50 @@ def resolve_path_contents(commit: Commit, info, path: str = None, filters=None):
314323 items = report_paths .full_filelist ()
315324 else :
316325 items = report_paths .single_directory ()
317- return {"results" : sort_path_contents (items , filters )}
326+
327+ # Fake pagination logic
328+ sorted_items = sort_path_contents (items , filters )
329+ total_items = len (sorted_items )
330+
331+ # Pagination calculation (first, after, last, before)
332+ start = 0
333+ end = total_items
334+
335+ # If `after` is provided, adjust start index
336+ if after :
337+ start = (
338+ next ((i for i , item in enumerate (sorted_items ) if item ["path" ] == after ), 0 )
339+ + 1
340+ )
341+
342+ # If `before` is provided, adjust end index
343+ if before :
344+ end = next (
345+ (i for i , item in enumerate (sorted_items ) if item ["path" ] == before ),
346+ total_items ,
347+ )
348+
349+ # Apply `first` or `last` limits
350+ if first :
351+ end = min (start + first , end )
352+ elif last :
353+ start = max (end - last , start )
354+
355+ paginated_items = sorted_items [start :end ]
356+
357+ # Prepare pagination info
358+ has_next_page = end < total_items
359+ has_previous_page = start > 0
360+
361+ return {
362+ "results" : paginated_items ,
363+ "pageInfo" : {
364+ "hasNextPage" : has_next_page ,
365+ "hasPreviousPage" : has_previous_page ,
366+ "startCursor" : paginated_items [0 ]["path" ] if paginated_items else None ,
367+ "endCursor" : paginated_items [- 1 ]["path" ] if paginated_items else None ,
368+ },
369+ }
318370
319371
320372@commit_bindable .field ("errors" )
0 commit comments