Trigger webhook registration programmatically

Hi all, I'm struggling a bit with the registration of Metaobject webhooks. As I know you'll need to add a filter in order to register a webhook. So I'm having a type:xxx filter in my webhook filter. In general this works when the Metaobject definition was created before you install the app. My situation is that I create the metaobject definitions in the install.ts (Installation procedure). Also to make sure that we don't have to this manually for each installation (in the onSuccess handler) But then it goes wrong. In the logs I see then: Error in field webhookSubscription: The specified filter is invalid, please ensure you specify the field(s) you wish to filter on. The system can only register the webhooks for Metaobjects if the Metaobject definition for type xxx is there. And the installation of webhooks is done before the onSuccess handler is executed. Is there a way to trigger the installation of webhooks programmatically? I couldn't find anything in the docs, but I think that would be really helpful. Then I can create all the definitions and afterwards re-run the webhook installation (in code). I want to prevent that I have to do this manually for each installation that we do. Thanks!
2 Replies
Smelvin
Smelvin2w ago
Hi Patrick, Gadget isnt able to track user created mutations for webhook registration unfortunately. As well there isnt a way to manually re-run registration, as that is handled by Gadget
Patrick Watzeels
Patrick WatzeelsOP2w ago
Thank you @[Gadget] Mark . There is also not a way to put this mutation in the run function so that it is executed before Gadget performs the Webhook registrations? I'm not sure when Gadget registrers the webhooks in the installation process Would be great if there was a function available that would trigger Gadget to re-run the registrations for a specific store (similar to when you press the "Register webhooks" button in the UI)

Did you find this page helpful?