//native
/**
* Get Fulfillment
* Get a fulfillment by numeric ID or GID: status, tracking info, delivery dates, location, line items and the fulfillment orders it fulfilled.
*/
export async function main(auth: RT.Shopify, fulfillment_id: string) {
const response = await fetch(
`https://${auth.store_name}.myshopify.com/admin/api/2026-10/graphql.json`,
{
method: "POST",
headers: {
"X-Shopify-Access-Token": auth.token,
"Content-Type": "application/json",
Accept: "application/json",
},
body: JSON.stringify({
query: `query ($id: ID!) { fulfillment(id: $id) { id legacyResourceId name status displayStatus createdAt updatedAt deliveredAt estimatedDeliveryAt inTransitAt totalQuantity requiresShipping trackingInfo { company number url } location { id name } order { id name } service { handle serviceName } fulfillmentLineItems(first: 250) { nodes { id quantity lineItem { id name sku } } } fulfillmentOrders(first: 10) { nodes { id status } } } }`,
variables: {
id: fulfillment_id.startsWith("gid://")
? fulfillment_id
: `gid://shopify/Fulfillment/${fulfillment_id}`,
},
}),
}
)
if (!response.ok) {
throw new Error(`${response.status} ${await response.text()}`)
}
const { data, errors } = await response.json()
if (errors) {
throw new Error(JSON.stringify(errors))
}
if (!data.fulfillment) {
throw new Error(`Fulfillment ${fulfillment_id} not found`)
}
return data.fulfillment
}
Submitted by hugo989 3 hours ago