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 Code | Description |
|---|---|
TRACKER_NOT_FOUND | Tracker ID not found |
INVALID_ADVERTISEMENT_KEY | Invalid advertisement key format |
DUPLICATE_NAME | Tracker name already exists |
PRODUCTION_RUN_NOT_FOUND | Production run ID not found |
Example Error Response
{
"errors": [
{
"message": "Tracker not found",
"extensions": {
"code": "TRACKER_NOT_FOUND",
"id": "123"
}
}
]
}
Best Practices
-
Advertisement Keys
- Use unique keys
- Follow BLE specifications
- Secure private keys
-
Status Management
- Handle transitions properly
- Update timestamps accurately
- Consider notifications
-
Production Run Association
- Validate production run exists
- Handle reassignment
- Update related records
-
Security
- Validate permissions
- Audit changes
- Log sensitive operations