Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend webhook registration to support metafield_namespaces #1186

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

fourseven
Copy link
Contributor

@fourseven fourseven commented Jul 26, 2023

I've added the ability to specify metafield_namespaces in webhook registration to allow these to be received from apps using this API. This is mostly following the patterns already there for fields.

The tests have gotten more complex, as before it was just fields or !fields, but I'm open to feedback (there; and anywhere in general).

This will also need minor updates in the shopify_app codebase to pass through the parameter.

Description

This change allows ShopifyApp.configuration.webhooks to set a metafield_namespaces parameter and pass that through to webhook registration.

This allows anyone using the shopify_app gem (once that's also improved) to have webhooks with metafields without needing to write custom code. The alternative is to manually register webhooks through graphql and manage it (removing all the benefits of the shopify_app features), or to update a webhook registered this way to add the metafieldNamespaces manually.

How has this been tested?

I have added automated tests around the areas I've changed, and included this branch in a shopify app I'm building which needs these features, and tested it through that as well for HTTP webhook registration. In more detail I:

  • Connected that app to a development store,
  • Configured ShopifyApp.configuration.webhooks with the new param,
  • Monkeypatched the ShopifyApp::WebhooksManager class to pass through the new field
  • Ran a purchase with my app which uses the checkout ui extensions to add a metafield to an order during checkout, and
  • Can confirm that on order completion the metafield I've requested from the webhook subscription appears in the webhook.

Checklist:

  • My commit message follow the pattern described in here
  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have updated the project documentation.
  • I have added a changelog line.

@fourseven
Copy link
Contributor Author

I have signed the CLA!

Copy link
Contributor

@mllemango mllemango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi there! Just wanted to say we totally see your PR and appreciate the thoughtful contribution. There are some changes that may affect how we deal with webhooks coming soon™️ and I'm also going to go through some of the other issues here first. All to say, we're going to have to come back to this one, thanks for you patience!

@fourseven
Copy link
Contributor Author

Hi @mllemango thank you for the update, even if it's no progress for now it's good to have that communicated.

@fourseven fourseven force-pushed the metafield-namespaces-webhooks branch 2 times, most recently from eb16086 to a702464 Compare September 28, 2023 21:30
@fourseven
Copy link
Contributor Author

Hi @mllemango how is the coming soon™️ coming? I've recently rebased this change (we still need this functionality) and I see #1189 was merged - are we likely to see any further updates soon?

Copy link
Contributor

@mllemango mllemango left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your patience, since I havent heard anything please go ahead and do the necessary updates for CI to pass!

I've added the ability to specify metafield_namespaces in webhook registration to allow these to be received from apps using this API. This is mostly following the patterns already there for fields.

Have updated:
- docs, adding in mention of the new parameter as well as ensuring it's referenced if using `fields` as well
- Updated the base Registration and child classes to have another keyword argument in the initializer
- Extended the tests, there's more complexity now as before it was just a boolean "are fields present" - but happy to adjust as needed.
- Changelog for this PR

shopify_app will also need adjusting to pass through the `metafield_namespaces` parameter but I can create that PR if there's appetite from this one.
@fourseven fourseven force-pushed the metafield-namespaces-webhooks branch from a702464 to 0761230 Compare October 8, 2023 21:16
@mllemango mllemango merged commit 175f68b into Shopify:main Oct 10, 2023
4 checks passed
@fourseven fourseven deleted the metafield-namespaces-webhooks branch October 13, 2023 03:17
fourseven added a commit to AMPeCommerce/shopify_app that referenced this pull request Nov 8, 2023
This is an extension on Shopify/shopify-api-ruby#1186, allowing users of the shopify_app ruby/rails library to register webhooks and expect them to return with metafields back.
fourseven added a commit to AMPeCommerce/shopify_app that referenced this pull request Nov 21, 2023
This is an extension on Shopify/shopify-api-ruby#1186, allowing users of the shopify_app ruby/rails library to register webhooks and expect them to return with metafields back.
garethson pushed a commit to garethson/shopify-api-ruby that referenced this pull request Dec 1, 2023
…1186)

I've added the ability to specify metafield_namespaces in webhook registration to allow these to be received from apps using this API. This is mostly following the patterns already there for fields.

Have updated:
- docs, adding in mention of the new parameter as well as ensuring it's referenced if using `fields` as well
- Updated the base Registration and child classes to have another keyword argument in the initializer
- Extended the tests, there's more complexity now as before it was just a boolean "are fields present" - but happy to adjust as needed.
- Changelog for this PR

shopify_app will also need adjusting to pass through the `metafield_namespaces` parameter but I can create that PR if there's appetite from this one.
fourseven added a commit to AMPeCommerce/shopify_app that referenced this pull request Dec 14, 2023
This is an extension on Shopify/shopify-api-ruby#1186, allowing users of the shopify_app ruby/rails library to register webhooks and expect them to return with metafields back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants