Connection
in package
Represents a Relay-style paginated connection.
Table of Contents
- $edges : array<string|int, mixed>
- Connection edges wrapping each node with its cursor.
- $nodes : array<string|int, mixed>
- The raw nodes without cursor wrappers.
- $page_info : PageInfo
- $total_count : int
- $sliced : bool
- Whether this connection has already been sliced.
- pre_sliced() : self
- Create a pre-sliced connection for the performance path.
- slice() : self
- Return a new Connection sliced according to the given pagination args.
Properties
$edges
Connection edges wrapping each node with its cursor.
public
array<string|int, mixed>
$edges
$nodes
The raw nodes without cursor wrappers.
public
array<string|int, mixed>
$nodes
$page_info
public
PageInfo
$page_info
$total_count
public
int
$total_count
$sliced
Whether this connection has already been sliced.
private
bool
$sliced
= false
When true, subsequent calls to slice() return $this immediately, preventing double-slicing when both the command class and the auto-generated resolver call slice().
Methods
pre_sliced()
Create a pre-sliced connection for the performance path.
public
static pre_sliced(array<string|int, Edge> $edges, PageInfo $page_info, int $total_count) : self
Use this when the DB query already applied pagination limits, so no further slicing is needed.
Parameters
- $edges : array<string|int, Edge>
-
The already-paginated edges.
- $page_info : PageInfo
-
The pagination info.
- $total_count : int
-
The total count before pagination.
Return values
self — A Connection marked as already sliced.slice()
Return a new Connection sliced according to the given pagination args.
public
slice(array<string|int, mixed> $args) : self
Applies the Relay cursor-based pagination algorithm: first narrow by after/before cursors, then take first N or last N from the remainder.
Parameters
- $args : array<string|int, mixed>
-
Pagination arguments with keys: first, last, after, before.
