Draft Order Line Item IDs: Not Stable?

Performing some tests/research on draft orders using webhooks and I noticed that if one adds a line item to an existing draft order the previous line items’ IDs change :weary_cat: Doing a bit of searching and I found a couple of posts that imply this is expected behavior:

Is this expected behavior and is it documented anywhere?

This is the first time I’ve seen IDs that can change. This is surprising and should be documented.

Hi @sshaw this is expected. draftOrderUpdate replaces the whole lineItems array rather than patching it, so every line item is recreated with a new ID on each update, and anything you leave out of the array disappears. We stopped storing those IDs anywhere and key on our own value written into the line item customAttributes instead, which also carries into the order line item properties once the draft is completed. Agreed it should be called out in the docs, the mutation reads like a patch and behaves like a replace.