Recalculate the route
Besides the updateNavigation
mutation, there is another way to alter the route in a navigation session. By using the recalculateNavigation
mutation a new route calculation can be enforced.
Mutation
To recalculate a route a navigation id
and current_location
need to be provided. Optionally, via
points, a state_of_charge
, and telemetry
data can be included to optimize the new route. If the mutation executed succesfully, OK
will be returned on the data object. The updates itself will be reflected on the navigationUpdatedById
subscription or the navigation
query. When using a query, please be aware that changes can take a little while to process.
To illustrate when this mutation should be used, two scenario's are described below.
1. Deviate from the route
In case a vehicle deviates from the calculated route (e.g. the driver takes a wrong exit), most navigation SDKs will detect this. It is recommended to hook into the event and send the location from the off route callback. Since recalculating a route can take a little while, make sure to not send multiple requests but wait until the navigationUpdatedById
returns a new route.
2. Changing the via points
The second use case for using this operation is to change the manually added via points. This allows the driver to change the order of the via points, to add new ones or to delete them. Note that via points that were already reached are eliminated automatically.
Arguments
input • NavigationRecalculateInput
• Required
Navigation recalculate input
Response
A response can either contain a data
or an
errors
object. The response header will always return
200
as a status code.
Data object
When successful, a data
object will be returned with the
requested fields. If there are no fields present the
data
object will return the operation name with the
appropriate return type. If the operation was a query, this output
will be an object of the schema’s query root type; if the operation
was a mutation, this output will be an object of the schema’s mutation
root type.
Error object
If unsuccessful, an errors
object will be returned with
more details in the extensions
object. The error object
can contain any of the following objects.
Error
EMPTY_ARRAY_NOT_ALLOWED
Array $NAME should have at least one value.
Error
INVALID_COORDINATES
Coordinates provided for $LOCATION are not valid.
Error
INVALID_UNIT
Provided unit type $TYPE for $LOCATION is not valid.
Error
INVALID_VALUE
Provided value $VALUE for $LOCATION is not valid. Expected value of type $EXPECTEDTYPE.
Error
NAVIGATION_TELEMETRY_INVALID
Field $TELEMETRYTYPE cannot be negative.
Error
NEGATIVE_VALUE_NOT_ALLOWED
Negative value for $LOCATION is not allowed.
Error
OCCUPANTS_BELOW_ALLOWED
Provided number of occupants for $LOCATION is not valid. The value must be at least 1.
Error
OPERATION_NOT_ALLOWED
You are not allowed to execute this operation. Enable it for the current application in the dashboard or reach out to customer support.
Error
TIRE_PRESSURE_BELOW_ALLOWED
Provided tire pressure is not valid. The value must be at least 1.
Error
ZERO_OR_NEGATIVE_VALUE_NOT_ALLOWED
Zero or negative value for $LOCATION is not allowed.