ManufacturerConnection
A connection to a list of Manufacturer items. This type implements cursor-based pagination to efficiently navigate through large sets of manufacturers.
Connection Structure
{
edges: [ManufacturerEdge]
nodes: [Manufacturer]
pageInfo: PageInfo!
totalCount: Int
}
Pagination Arguments
The ManufacturerConnection
supports the following pagination arguments to control the slice of data returned:
Argument | Type | Description |
---|---|---|
first | Int | Returns the first n items from the list. Must be a positive integer. |
last | Int | Returns the last n items from the list. Must be a positive integer. |
before | String | Returns items before the specified cursor. Used for backward pagination. |
after | String | Returns items after the specified cursor. Used for forward pagination. |
Constraints:
first
andlast
cannot be used together in the same query.before
andafter
are opaque cursor strings returned in the edges.- Pagination arguments must be combined logically to navigate pages efficiently.
PageInfo Structure
The pageInfo
field provides metadata about the current page of results:
{
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String
endCursor: String
}
hasNextPage
: Indicates if there are more items after the current page.hasPreviousPage
: Indicates if there are more items before the current page.startCursor
: The cursor of the first item in the current page.endCursor
: The cursor of the last item in the current page.
These fields help clients determine whether to show pagination controls and how to fetch the next or previous page.
Usage Examples
Basic Pagination
Fetch the first 5 manufacturers with their IDs and names:
{
manufacturers(first: 5) {
nodes {
id
name
}
pageInfo {
hasNextPage
endCursor
}
totalCount
}
}
Forward Pagination
Fetch the next 5 manufacturers after a given cursor:
{
manufacturers(first: 5, after: "YXJyYXljb25uZWN0aW9uOjQ=") {
edges {
cursor
node {
id
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
Backward Pagination
Fetch the previous 5 manufacturers before a given cursor:
{
manufacturers(last: 5, before: "YXJyYXljb25uZWN0aW9uOjEw") {
edges {
cursor
node {
id
name
}
}
pageInfo {
hasPreviousPage
startCursor
}
}
}
Cursor-based Navigation
Navigate pages using cursors obtained from previous queries:
{
manufacturers(first: 3) {
edges {
cursor
node {
id
name
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
Use the endCursor
value from this response as the after
argument in the next query to fetch subsequent pages.
Combined with Filtering
If the API supports filtering by manufacturer name (hypothetical example), combine pagination with filtering:
{
manufacturers(first: 5, after: "YXJyYXljb25uZWN0aW9uOjU=", filter: { nameContains: "Acme" }) {
nodes {
id
name
}
pageInfo {
hasNextPage
endCursor
}
}
}
Note: Filtering arguments depend on API support and are not defined in this connection type.
Edge Type
The ManufacturerEdge
represents a single edge in the connection and contains:
{
cursor: String!
node: Manufacturer
}
cursor
: An opaque string used for pagination.node
: The actualManufacturer
object.
Edges link the pagination cursors to the underlying nodes, enabling precise navigation.
Pagination Best Practices
- Use
first
withafter
for forward pagination andlast
withbefore
for backward pagination. - Avoid requesting very large page sizes to reduce response times.
- Always check
pageInfo.hasNextPage
andpageInfo.hasPreviousPage
before attempting to fetch additional pages. - Use cursors returned in
edges.cursor
orpageInfo
to navigate pages reliably. - Handle empty results gracefully by checking if
nodes
oredges
arrays are empty. - Combine pagination with filtering and sorting where supported to reduce data volume.
Performance Considerations
- Cursor-based pagination is efficient for large datasets as it avoids offset-based performance pitfalls.
- Limit the number of items requested per page to balance between network usage and user experience.
- Use the
totalCount
field sparingly, as counting large datasets can impact performance. - Cache cursors when possible to improve user navigation experience.
Related Types
ManufacturerEdge
: Represents an edge containing a cursor and aManufacturer
node.Manufacturer
: The node type representing a manufacturer entity.PageInfo
: Provides pagination metadata such as cursors and page availability.
Notes
- The API currently requires no authentication for querying manufacturers, but this may change in future versions.
- Always implement error handling for cases such as invalid cursors or out-of-range pagination arguments.
- When no results are returned,
nodes
andedges
will be empty arrays, andpageInfo.hasNextPage
andhasPreviousPage
will befalse
. - Single-page results will have both
hasNextPage
andhasPreviousPage
set tofalse
.