Skip to main content

How to assign order to driver

GraphQL mutation

The AssignToDriver mutation allows assigning one or multiple orders to a specific driver. This enables efficient management of driver assignments.

const fetch = require("node-fetch")

fetch("https://backend.impargo.eu/", {
"method": "POST",
"headers": {
"authorization": token,
"content-type": "application/json",
},
"body": JSON.stringify([{
"operationName": "AssignToDriver",
"variables": {
"driver": "5ce19e186ef9ef001461077f",
"orders": ["6714206871534cef742a9b7f"]
},
"query": `
mutation AssignToDriver($driver: ObjectId!, $orders: [ObjectId!]!) {
assign(driver: $driver, orders: $orders) {
...DriverListItemData
__typename
}
}

fragment DriverDeviceSettingsData on DriverDeviceSettings {
activityRecognition
locationProviderStatus
locationProviderEnabled
isIgnoringBatteryOptimization
isPowerSaveMode
powerManagerNeeded
powerManagerLastSeenAt
appVersion
androidVersion
device
isPowerSaveMode
updatedAt
__typename
}

fragment DriverAppData on DriverApp {
name
telephone
trackingEnabled
deviceSettings {
...DriverDeviceSettingsData
__typename
}
__typename
}

fragment DriverIntegrationDetailsData on DriverIntegrationDetails {
... on WebfleetDriverIntegrationDetails {
licensePlateNumber
fuelLevel
name
telephone
__typename
}
... on TrimbleDriverIntegrationDetails {
name
telephone
__typename
}
__typename
}

fragment PositionData on Position {
_id
timestamp
battery {
level
__typename
}
geoCoordinates {
coordinates
heading
speed
__typename
}
__typename
}

fragment DriverAssignedOrdersFragment on AssignedOrders {
hasNext
items {
_id
order
orderDetails {
_id
reference
status
__typename
}
status
updatedAt
__typename
}
__typename
}

fragment OrderFirstLastStopData on Order {
_id
firstStop {
location {
country
city
zipcode
coordinates {
lat
lon
__typename
}
__typename
}
date {
from
to
__typename
}
time {
from
to
__typename
}
__typename
}
lastStop {
location {
country
city
zipcode
coordinates {
lat
lon
__typename
}
__typename
}
date {
from
to
__typename
}
time {
from
to
__typename
}
__typename
}
__typename
}

fragment AddressesCategoryData on AddressesCategory {
_id
name
color
icon
isDefault
__typename
}

fragment AdditionalFieldData on AdditionalField {
customFieldId
value
label
visibility
__typename
}

fragment AddressFromToTimeData on FromToTime {
from
to
__typename
}

fragment AddressData on Address {
_id
companyName
label
country
zipcode
city
street
contactPerson
phoneNumber
comment
email
coordinates {
lat
lon
__typename
}
category {
...AddressesCategoryData
__typename
}
additionalDetails {
...AdditionalFieldData
__typename
}
isOneTimeAddress
timeWindows {
...AddressFromToTimeData
__typename
}
waitingTimeMinutes
__typename
}

fragment BaseStopData on Stop {
_id
status
operationType
referenceStops
comment
statusUpdateComment
waitingTimeMinutes
plannedArrivalTime
plannedDepartureTime
location {
country
city
zipcode
coordinates {
lat
lon
__typename
}
__typename
}
address {
...AddressData
__typename
}
date {
from
to
__typename
}
time {
from
to
__typename
}
additionalTimeWindows {
from
to
__typename
}
__typename
}

fragment FleetCurrentOrderView on Order {
...OrderFirstLastStopData
load {
length
type
weight
bodyType
value
price
equipmentExchange
__typename
}
reference
status
isFused
route {
distance
time
stopsCount
stops {
...BaseStopData
__typename
}
__typename
}
comment
__typename
}

fragment AlertData on Alert {
_id
isResolved
alertType
priority
driver
order
stop
driverLocation {
lat
lon
__typename
}
__typename
}

fragment DriverListItemData on Driver {
_id
displayName
status
activated
isActive
firebaseUid
driverApp {
...DriverAppData
__typename
}
integration {
_id
type
filterGpsDataByOtId
details {
...DriverIntegrationDetailsData
__typename
}
__typename
}
currentPosition {
...PositionData
__typename
}
assigned: orders(sortBy: {rank: 1}, query: {statusFilter: [ASSIGNED]}) {
...DriverAssignedOrdersFragment
__typename
}
delivered: orders(
paginate: {limit: 3}
sortBy: {rank: -1}
query: {statusFilter: [DELIVERED]}
) {
...DriverAssignedOrdersFragment
__typename
}
currentOrder {
_id
orderDetails {
...FleetCurrentOrderView
__typename
}
__typename
}
alerts {
...AlertData
__typename
}
__typename
}
`
}]),
});


[
{
"data":{
"assign":[
{
"_id":"5ce19e186ef9ef001461077f",
"displayName":"Beshoy",
"status":"ORDERS_ASSIGNED",
"activated":true,
"isActive":true,
"firebaseUid":"rsGYYRHWYWVV1VofeBlzX4T62N72",
"driverApp":{
"name":"Beshoy",
"telephone":"+201112565785",
"trackingEnabled":true,
"deviceSettings":null,
"__typename":"DriverApp"
},
"integration":null,
"currentPosition":null,
"assigned":{
"hasNext":false,
"items":[
{
"_id":"6714220e80b11b7978d4b267",
"order":"6714206871534cef742a9b7f",
"orderDetails":{
"_id":"6714206871534cef742a9b7f",
"reference":"1302 / IT 00165 - DE 78052 copy copy",
"status":"ASSIGNED",
"__typename":"Order"
},
"status":"ASSIGNED",
"updatedAt":"2024-10-19T21:18:06.394Z",
"__typename":"AssignedOrder"
}
],
"__typename":"AssignedOrders"
},
"delivered":{
"hasNext":false,
"items":[

],
"__typename":"AssignedOrders"
},
"currentOrder":{
"_id":"6714220e80b11b7978d4b267",
"orderDetails":{
"_id":"6714206871534cef742a9b7f",
"firstStop":{
"location":{
"country":"it",
"city":"00165 Rome, via gregorio vii 213",
"zipcode":"00165",
"coordinates":{
"lat":41.89536,
"lon":12.44575,
"__typename":"Coordinates"
},
"__typename":"Location"
},
"date":{
"from":"2024-02-13T09:59:38.479Z",
"to":"2024-02-13T09:59:38.479Z",
"__typename":"FromToDate"
},
"time":{
"from":"08:00",
"to":"17:00",
"__typename":"FromToTime"
},
"__typename":"MainStopInfo"
},
"lastStop":{
"location":{
"country":"de",
"city":"Villingen-Schwenningen",
"zipcode":"78052",
"coordinates":{
"lat":48.06203,
"lon":8.49491,
"__typename":"Coordinates"
},
"__typename":"Location"
},
"date":{
"from":"2024-02-13T09:59:38.479Z",
"to":"2024-02-13T09:59:38.479Z",
"__typename":"FromToDate"
},
"time":{
"from":"08:00",
"to":"17:00",
"__typename":"FromToTime"
},
"__typename":"MainStopInfo"
},
"__typename":"Order",
"load":{
"length":null,
"type":null,
"weight":24,
"bodyType":"ANY",
"value":null,
"price":null,
"equipmentExchange":false,
"__typename":"Load"
},
"reference":"1302 / IT 00165 - DE 78052 copy copy",
"status":"ASSIGNED",
"isFused":false,
"route":{
"distance":972.155,
"time":12.825555555555555,
"stopsCount":2,
"stops":[
{
"_id":"6714206871534cef742a9b74",
"status":"PENDING",
"operationType":null,
"referenceStops":[

],
"comment":null,
"statusUpdateComment":null,
"waitingTimeMinutes":null,
"plannedArrivalTime":null,
"plannedDepartureTime":null,
"location":{
"country":"it",
"city":"00165 Rome, via gregorio vii 213",
"zipcode":"00165",
"coordinates":{
"lat":41.89536,
"lon":12.44575,
"__typename":"Coordinates"
},
"__typename":"Location"
},
"address":null,
"date":{
"from":"2024-02-13T09:59:38.479Z",
"to":"2024-02-13T09:59:38.479Z",
"__typename":"FromToDate"
},
"time":{
"from":"08:00",
"to":"17:00",
"__typename":"FromToTime"
},
"additionalTimeWindows":[

],
"__typename":"Stop"
},
{
"_id":"6714206871534cef742a9b79",
"status":"PENDING",
"operationType":null,
"referenceStops":[

],
"comment":null,
"statusUpdateComment":null,
"waitingTimeMinutes":null,
"plannedArrivalTime":null,
"plannedDepartureTime":null,
"location":{
"country":"de",
"city":"Villingen-Schwenningen",
"zipcode":"78052",
"coordinates":{
"lat":48.06203,
"lon":8.49491,
"__typename":"Coordinates"
},
"__typename":"Location"
},
"address":null,
"date":{
"from":"2024-02-13T09:59:38.479Z",
"to":"2024-02-13T09:59:38.479Z",
"__typename":"FromToDate"
},
"time":{
"from":"08:00",
"to":"17:00",
"__typename":"FromToTime"
},
"additionalTimeWindows":[

],
"__typename":"Stop"
}
],
"__typename":"Route"
},
"comment":null
},
"__typename":"AssignedOrder"
},
"alerts":[

],
"__typename":"Driver"
}
]
}
}
]