Skip to main content

Tracker Connection Types

Types for handling paginated tracker data and connections.

TrackerConnection

Represents a paginated connection of trackers.

type TrackerConnection {
"""
List of edges containing the nodes and cursors.
"""
edges: [TrackerEdge!]!

"""
Information about the pagination state.
"""
pageInfo: PageInfo!

"""
Total count of trackers matching the query.
"""
totalCount: Int!
}

TrackerEdge

Represents a single tracker node in the connection with its cursor.

type TrackerEdge {
"""
Opaque cursor for pagination.
"""
cursor: String!

"""
The tracker node.
"""
node: Tracker!
}

PageInfo

Contains information about the current page state.

type PageInfo {
"""
Whether there are more items after the current page.
"""
hasNextPage: Boolean!

"""
Whether there are items before the current page.
"""
hasPreviousPage: Boolean!
}

TrackerOrderField

Enum for specifying tracker ordering fields.

enum TrackerOrderField {
"""
Order by tracker name.
"""
NAME

"""
Order by timestamp of latest location.
"""
TIMESTAMP

"""
Order by tracker ID.
"""
ID

"""
Order by current status.
"""
STATUS

"""
Order by location coordinates.
"""
LOCATION

"""
Order by nearest city name.
"""
NEAREST_CITY
}

Example Usage

Basic Pagination Query

query GetTrackers {
trackersConnection(
offset: 0
limit: 10
orderBy: { field: TIMESTAMP, direction: DESC }
) {
edges {
cursor
node {
id
name
currentStatus
latestLocation {
timestamp
nearestCity
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
}
totalCount
}
}

Filtered Pagination Query

query GetFilteredTrackers {
trackersConnection(
offset: 0
limit: 10
orderBy: { field: NAME, direction: ASC }
filters: {
brandId: "123"
currentStatuses: [IN_TRANSIT, DELIVERED]
productionRunIds: ["456", "789"]
}
) {
edges {
cursor
node {
id
name
currentStatus
productionRun {
id
description
brand {
name
}
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
}
totalCount
}
}

Best Practices

  1. Pagination

    • Use reasonable page sizes (10-50 items)
    • Always check pageInfo for more data
    • Store cursors for backward navigation
  2. Ordering

    • Consider performance implications of different ordering fields
    • Use appropriate indexes for commonly used ordering fields
    • Handle null values appropriately
  3. Filtering

    • Combine filters efficiently
    • Use appropriate indexes for filtered fields
    • Consider caching frequently used filter combinations
  4. Performance

    • Request only needed fields
    • Use appropriate batch sizes
    • Consider implementing cursor-based pagination for large datasets