Update Tracker Location
The updateTrackerLocation mutation allows administrators to request an immediate update of a tracker's location.
Permissions
This mutation requires admin privileges. The user must have a valid JWT token with the admin role.
You can check if a user has admin privileges by using the currentUser query:
query GetCurrentUser {
currentUser {
id
name
email
roles
}
}
If the roles array in the response includes "admin", the user can use this mutation:
{
"data": {
"currentUser": {
"id": "3",
"name": "Admin User",
"email": "admin@example.com",
"roles": ["admin"]
}
}
}
Input
| Field | Type | Description |
|---|---|---|
trackerId | ID! | The ID of the tracker to update |
Response
| Field | Type | Description |
|---|---|---|
success | Boolean! | Whether the request was successful |
message | String! | A message describing the result |
trackerId | ID! | The ID of the tracker that was updated |
Example
Request
mutation UpdateTrackerLocation($trackerId: ID!) {
updateTrackerLocation(trackerId: $trackerId) {
success
message
trackerId
}
}
Variables:
{
"trackerId": "123"
}
Response
{
"data": {
"updateTrackerLocation": {
"success": true,
"message": "Tracker location update request sent to fetcher service",
"trackerId": "123"
}
}
}
Error Handling
| Error | Description |
|---|---|
Admin role required for this operation | The user does not have admin privileges |
Tracker with ID X not found | The specified tracker does not exist |
Invalid tracker ID format | The tracker ID is not in the correct format |
Implementation Details
When this mutation is called:
- The server verifies that the user has admin privileges
- The server checks that the tracker exists
- The server publishes a message to the Redis channel
tracker:update:requests - The fetcher service processes the request and retrieves the latest data
- When complete, the fetcher publishes a notification to the Redis channel
socket:notifications - Connected clients receive a
tracker_location_updatedSocket.IO event with the new location data
Socket.IO Integration
After the fetcher service processes the request, it sends a notification through Redis. The Socket.IO server forwards this notification to connected clients, which will receive an event like this:
{
"type": "tracker_location_updated",
"trackerId": "123",
"success": true,
"message": "Successfully updated tracker ABC123, found 5 reports, stored 2 new reports",
"location": {
"id": "456789",
"timestamp": "2025-05-06T12:53:25",
"nearestCity": "London",
"location": {
"latitude": 51.5074,
"longitude": -0.1278
},
"confidence": 3,
"horizontalAccuracy": 10.5
}
}