Updating a shopify synced model shortly after creating a record?
- I'm creating a shopify app that allows users to create and manage shopify sellingPlans, although my issue isn't exclusive to selling plans. - When clicking 'create' in the UI, the selling plan is created through the Shopify Admin API in a global action. - The selling plans sync back to gadget using built in webhooks. - The UI gives the option to add additional fields that don't exist on the native shopify selling plan fields (eg. Enabled / Disabled state) so I've added these additional fields on the data model inside gadget.
My intention was to create the sellingPlan through the admin API, when the response returns, find the record in gadget and populate the custom field all in one UI action.
However just because the admin api returned a successful response, doesn't mean the webhook has fired and gadget has created the record.
So after a successful response when I try to find the sellingPlan in gadget with the specific ID, its not there.
So I'm wondering if theres a way around this please? I'm hoping I'm missing something obvious.
Potential solutions - I've not touched background actions yet but not sure if thats the right approach. - I could move the custom field into a 2nd UI, which appears after the selling plan has been created, so a user creates a selling plan, and then as part of another UI step populates the custom field - I was thinking I could also push the sellingPlan id and the value for the custom fields into a temporary custom data model (eg: pending_custom_fields) and then in sellingPlan create onSuccess (assuming this fires when the webhook creates records), query the data model and check if any any records match the selling plan ids, populate the fields and delete the record from the temporary data model when complete, but this seems a massive long way around.