Skip to content

Conversation

jamieguerrero
Copy link
Contributor

@jamieguerrero jamieguerrero commented Aug 5, 2025

Add support for extension context in app module versions

TL;DR

Fixes https://github.com/shop/issues-develop/issues/17833

Added support for the target field in app module versions to enhance extension configuration capabilities.

What changed?

  • Added the target field to the GraphQL query for released app modules
  • Updated the AppModuleVersion interface to include the optional target property
  • Modified the appExtensionRegistrations method to include the context field in the activeVersion object when both config and target are present
  • Added comprehensive tests to verify the behavior with various combinations of config and context values

How to test?

  1. Run the test suite to verify the new functionality:
    npm test packages/app/src/cli/utilities/developer-platform-client/app-management-client.test.ts
    
  2. Test the CLI with an app that uses extensions with context values:
    • Create an app with extensions that include target data
    • Verify that the target data is properly included as context in the extension registrations
    • Check that the context is correctly passed to the UI when viewing extensions

Why make this change?

This change enables extensions to store and retrieve contextual information alongside their configuration. The target field (mapped to context in the client) provides a way for extensions to maintain state or metadata that isn't part of the user-configurable settings but is necessary for proper extension functionality. This enhancement improves the flexibility of the extension system and allows for more sophisticated extension behaviors.

Copy link
Contributor Author

jamieguerrero commented Aug 5, 2025

@jamieguerrero jamieguerrero marked this pull request as ready for review August 5, 2025 19:47
@jamieguerrero jamieguerrero requested a review from a team as a code owner August 5, 2025 19:47
Copy link
Contributor

github-actions bot commented Aug 5, 2025

We detected some changes at packages/*/src and there are no updates in the .changeset.
If the changes are user-facing, run pnpm changeset add to track your changes and include them in the next release CHANGELOG.

Caution

DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release.

@jamieguerrero jamieguerrero force-pushed the 08-05-pass_app_module_context_through_to_registration_s_activeversion_if_it_exists branch 2 times, most recently from f080216 to b7a6f0d Compare August 5, 2025 20:36
@jamieguerrero
Copy link
Contributor Author

/snapit

Copy link
Contributor

github-actions bot commented Aug 5, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
78.33% (+0.03% 🔼)
13176/16822
🟡 Branches
72.4% (+0.1% 🔼)
6434/8887
🟡 Functions
78.4% (+0.02% 🔼)
3419/4361
🟡 Lines
78.7% (+0.03% 🔼)
12467/15842
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / url_prepender.ts
100% 100% 100% 100%
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟢
... / app_config_webhook_subscription.ts
100%
50% (-16.67% 🔻)
100% 100%
🟡
... / identifiers-extensions.ts
75.78% (+0.38% 🔼)
68.12% (-0.54% 🔻)
100%
77.39% (+0.4% 🔼)

Test suite run success

3126 tests passing in 1324 suites.

Report generated by 🧪jest coverage report action from 1afbe62

Copy link
Contributor

github-actions bot commented Aug 5, 2025

🫰✨ Thanks @jamieguerrero! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

pnpm i -g @shopify/[email protected]

Tip

If you get an ETARGET error, install it with NPM and the flag --@shopify:registry=https://registry.npmjs.org

Caution

After installing, validate the version by running just shopify in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@jamieguerrero jamieguerrero force-pushed the 08-05-pass_app_module_context_through_to_registration_s_activeversion_if_it_exists branch from b7a6f0d to 3df350b Compare August 6, 2025 18:13
activeVersion: mod.config
? {
config: JSON.stringify(mod.config),
...(mod.context && {context: mod.context}),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main change. Currently, some dashboard managed extensions are failing at importing because we are not passing the app module's context along here and it is causing things to fail here.

@jamieguerrero jamieguerrero force-pushed the 08-05-pass_app_module_context_through_to_registration_s_activeversion_if_it_exists branch 4 times, most recently from cd34ed7 to d99dc1e Compare August 7, 2025 18:11
@jamieguerrero jamieguerrero force-pushed the 08-05-pass_app_module_context_through_to_registration_s_activeversion_if_it_exists branch from d99dc1e to 1afbe62 Compare August 7, 2025 18:44
@jamieguerrero jamieguerrero added this pull request to the merge queue Aug 11, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 11, 2025
@isaacroldan isaacroldan added this pull request to the merge queue Aug 12, 2025
Merged via the queue into main with commit 80909e4 Aug 12, 2025
50 of 52 checks passed
@isaacroldan isaacroldan deleted the 08-05-pass_app_module_context_through_to_registration_s_activeversion_if_it_exists branch August 12, 2025 11:24
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.

3 participants