No able to get calculatedLineItem of specific item in order to update order

Hi I am trying to update an item in the order. So I am using this mutation

mutation ($id: ID!) {
                orderEditBegin(id: $id){
                    calculatedOrder{
                        id
                        lineItems(first:10) {
                            edges {
                              node {
                                id
                                quantity
                              }
                            }
                        }
                    }
                    userErrors {
                      field
                      message
                    }
                }
            }

Is there a way to pass itemID to get the calculatedLineItemID of a specific line item?

Hey @vikasranjan - you should be able to do this using the OrderEditAddVariant mutation - once you add a new item to the order, it should automatically re-calculate the order. The orderEditBegin mutation is just used to trigger the order editing process - sort of like a failsafe so that orders aren’t edited by mistake, if that makes sense. The only variable that is supported by that mutation is the order ID.

If you needed to remove an item from an order in addition to adding a new item, you can use the OrderEditSetQuantity mutation. Once the edits are complete you can then use the OrderEditCommit mutation to finalize the edit.

Hope this helps - let us know if we can clarify anything further for you.

Al | Shopify Developer Support.

I know the OrderEditSetQuantity mutation but it needs a “ID of the calculated line item to edit” but I am confused about how to get this ID?

Agree, this is really confusing and poorly documented on the Shopify side. Took some time and experimenting to figure it out.

Use the original order line items IDs - they will look like gid://shopify/LineItem/12345678901234 and change to gid://shopify/CalculatedLineItem/12345678901234

Get original order line items:

query Order {
    order(id: "gid://shopify/Order/1234567890123") {
        fulfillmentOrders(first: 250) {
            nodes {
                lineItems(first: 250) {
                    nodes {
                        id
                        totalQuantity
                        sku
                        productTitle
                        lineItem {
                            id
                        }
                    }
                }
            }
        }
    }
}
{
    "data": {
        "order": {
            "fulfillmentOrders": {
                "nodes": [
                    {
                        "lineItems": {
                            "nodes": [
                                {
                                    "id": "gid://shopify/FulfillmentOrderLineItem/12345678901234",
                                    "totalQuantity": 2,
                                    "sku": "1234567890",
                                    "productTitle": "Product Title",
                                    "lineItem": {
                                        "id": "gid://shopify/LineItem/12345678901234"
                                    }
                                }
                            ]
                        }
                    }
                ]
            }
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 278,
            "actualQueryCost": 6,
            "throttleStatus": {
                "maximumAvailable": 2000,
                "currentlyAvailable": 1994,
                "restoreRate": 100
            }
        }
    }
}

Use returned lineItem id as CalculatedLineItem id to set new quantity:

mutation OrderEditSetQuantity {
    orderEditSetQuantity(
        id: "gid://shopify/CalculatedOrder/123456789012"
        lineItemId: "gid://shopify/CalculatedLineItem/12345678901234"
        quantity: 2
    ) {
        calculatedLineItem {
            id
            quantity
        }
        calculatedOrder {
            id
        }
        userErrors {
            field
            message
        }
    }
}