Tags added via Admin Block mutation are overwritten when the page is later saved - Draft Orders

I have an Admin block extension on the Draft Order details page that updates the draft order’s tags using the addTags mutation.

The mutation itself works as expected, however I’m running into an issue related to the Draft Order page save behaviour.

Issue

If a merchant uses the block to add tags and then, without refreshing the page, makes any further changes to the draft order (for example editing line items or notes) and clicks the native Save button, the tags that were added via the mutation are not updated.

It appears that when the Draft Order page is saved, Shopify re-applies the previously loaded draft order state, which overwrites the tag changes that were made via the Admin API mutation.

Question

Is there any supported way for an Admin block extension to do one of the following:

  • Trigger or participate in the Draft Order page save from within the block

  • Refresh or rehydrate the current Draft Order data after a successful mutation

  • Prevent the Draft Order page save from overwriting changes made via the Admin API

I’ve reviewed the Block Extension API but it seems that block extensions are limited to the block scope and don’t have access to the page save lifecycle or refresh mechanisms.

So I guess what I’m asking is what is the recommended pattern for safely updating Draft Orders from an Admin block when the page may have unsaved changes?

API Version: 2025-10 (latest)
App: Admin Block Extension Only App
Created using CLI: shopify app init

Hi @JayLewis

I believe you’re encountering a limitation of the API. On the Draft Order details page, Shopify keeps its own in-memory copy of the draft order (including tags). When your Admin block calls addTags, the backend draft order is updated, but the main page’s in-memory state isn’t. Later, when the merchant edits something else (like line items or notes) and hits the native Save, the page submits its own stale copy of the draft order, which can overwrite the tag changes your mutation made. There’s no built-in conflict resolution between Admin’s local state and your out-of-band Admin API writes.

Within current APIs, a block extension can’t truly “join” the Draft Order’s native save or force the page to re-fetch data. You can integrate with the contextual save bar using the Form component: when your inputs change, the page shows the save bar, and when the merchant clicks Save or Discard, your block’s onSubmit / onReset run. You can also re-query the Draft Order via the extension’s query API so your block’s own UI stays in sync after mutations. But you can’t make the core Draft Order page wait on your mutation, refresh its internal state from your data, or prevent it from overwriting your tag changes when it saves.

Because of that, the recommended patterns are workarounds that reduce, rather than eliminate, conflicts. One approach is to treat your block as the “pending changes” UI for tags: don’t call addTags immediately, instead store tag changes in local state and apply them via a mutation in Form.onSubmit, so they conceptually happen along with the page’s save. Another approach is to provide explicit “Save/Apply tags” actions in your block (or an Admin Action modal) and clearly signal that your block is the source of truth, accepting that the main page might show stale tags until a reload. In all cases, there’s currently no supported way for a block to stop the native Draft Order save from overwriting Admin API changes.

Hi @Liam-Shopify

Thanks for getting back so quickly and with such a good answer. This is basically the method I was looking for!

I’ve now add the form component to wrap the inputs and placed my function in the onSubmit event (It feels now this is kind of a no brainer but completely over looked it in the docs). It’s nice now that every page save runs my api call therefor updating the tags.

I have noticed a slight issue which I’ll now have to solve. My api calls take longer than the page saving which then throws a polaris banner error “The app did not save your changes. Try again or discard your changes in this app.”. I’m only fetching, removing then adding tags but this is a little too much for Shopify’s liking it seems. I have now switched to draftOrderUpdate instead so I can make one request and not have to remove then add, but still getting this error. I’m having a look into it now but again thank you for your solution, this has saved a big headache.

I fixed the app block error, I was trying to run my functions after event.waitUntil(fetch(‘app:save/data’)) which were obviously running after the page save. Instead I replace this line with event.waitUntil( myFunction()) which does the trick.

Again, appreciate the initial help!