Skip to main content

Tracker Mutations

Mutations for managing trackers.

createTracker

Creates a new tracker.

Arguments

"""
Input for creating a tracker.
"""
input CreateTrackerInput {
"""
Name of the tracker.
"""
name: String!

"""
Advertisement key used for BLE identification.
"""
advertisementKey: String!

"""
Private key for the tracker.
"""
privateKey: String!

"""
Optional production run ID to associate with.
"""
productionRunId: ID
}

Example Mutation

mutation CreateTracker {
createTracker(
input: {
name: "Tracker 123"
advertisementKey: "adv_key_123"
privateKey: "priv_key_123"
productionRunId: "run_456"
}
) {
id
name
advertisementKey
hashedAdvertisementKey
currentStatus
productionRun {
id
description
}
}
}

updateTracker

Updates an existing tracker.

Arguments

"""
Input for updating a tracker.
"""
input UpdateTrackerInput {
"""
Optional new name.
"""
name: String

"""
Optional last report requested timestamp.
"""
lastReportRequested: DateTime

"""
Optional last report received timestamp.
"""
lastReportReceived: DateTime

"""
Optional new status.
"""
currentStatus: TrackerStatus

"""
Optional production run ID to associate with.
"""
productionRunId: ID
}

Example Mutation

mutation UpdateTracker {
updateTracker(
id: "123"
input: {
name: "Updated Tracker 123"
currentStatus: IN_TRANSIT
productionRunId: "run_789"
}
) {
id
name
currentStatus
productionRun {
id
description
}
}
}

deleteTracker

Deletes a tracker.

Arguments

"""
ID of the tracker to delete.
"""
id: ID!

Example Mutation

mutation DeleteTracker {
deleteTracker(id: "123")
}

Error Handling

Common Errors

Error CodeDescription
TRACKER_NOT_FOUNDTracker ID not found
INVALID_ADVERTISEMENT_KEYInvalid advertisement key format
DUPLICATE_NAMETracker name already exists
PRODUCTION_RUN_NOT_FOUNDProduction run ID not found

Example Error Response

{
"errors": [
{
"message": "Tracker not found",
"extensions": {
"code": "TRACKER_NOT_FOUND",
"id": "123"
}
}
]
}

Best Practices

  1. Advertisement Keys

    • Use unique keys
    • Follow BLE specifications
    • Secure private keys
  2. Status Management

    • Handle transitions properly
    • Update timestamps accurately
    • Consider notifications
  3. Production Run Association

    • Validate production run exists
    • Handle reassignment
    • Update related records
  4. Security

    • Validate permissions
    • Audit changes
    • Log sensitive operations