GraphQL Mapping CalculatedLineItem IDs to LineItem IDs

Highlighted
New Member
1 0 0

Hello,

I'm trying to add a discount on an order line item and can't find a way to identify it with the LineItem ID I have when fetching the order through the REST API.

Order fetched from the REST API:

{'id': 1234,
 'email': 'email@domain.com',
 <...>
 'line_items': [{'id': 5678,
                 'variant_id': 111,
                 <...>
                 'quantity': 1,
                 'admin_graphql_api_id': 'gid://shopify/LineItem/5678'},
                {'id': 9000,
                 'variant_id': 555,
                 <...>
                 'quantity': 1,
                 'admin_graphql_api_id': 'gid://shopify/LineItem/9000'}],
 <...>
}



When calling the mutation orderEditBegin, it returns CalculatedLineItems with IDs that I can't map to the LineItem IDs I have outside of the mutation.

Here's the orderEditBegin mutation:

mutation beginEdit($id: ID!){
    orderEditBegin(id: $id){
        calculatedOrder {
            id
            lineItems(first:30){
                edges {
                    node {
                        id
                        quantity
                        variant {
                            sku
                            price
                            taxable
                            product {
                                productType
                                options {
                                    id
                                    name
                                    position
                                    values
                                }
                            }
                        }
                        customAttributes {
                            key
                            value
                        }
                    }
                }
            }
        }
    }
}

  

0 Likes