Skip to content

Add app execute command for GraphQL operations - #6686

Merged
nickwesselman merged 19 commits into
mainfrom
shopify_app_execute
Dec 5, 2025
Merged

nickwesselman merged 19 commits into
mainfrom
shopify_app_execute

Conversation

@nickwesselman

@nickwesselman nickwesselman commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

To provide developers with a convenient way to execute GraphQL queries and mutations directly from the CLI, making it easier to interact with Shopify's Admin API.

WHAT is this pull request doing?

Adds a new shopify app execute command that allows developers to:

  • Execute GraphQL queries and mutations against a store
  • Provide variables in JSON format
  • Output results to STDOUT or a file
  • Specify API version

This PR also:

  • Refactors shared code between the new execute command and existing bulk execute command
  • Creates helper utilities for preparing execution context
  • Adds documentation for the new command

How to test your changes?

  1. Run a simple query:
  2. Run a query with variables:
  3. Pipe a query via stdin:
  4. Output to a file:
  5. Verify correct output streams:

echo "query { shop { name } }" | shopify app execute 2>/dev/null | jq .shop.name

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

nickwesselman commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor Author

@nickwesselman nickwesselman changed the title initial implementation of 'app execute' Add app execute command for GraphQL operations Dec 4, 2025
@github-actions

github-actions Bot commented Dec 4, 2025 •

Copy link
Copy Markdown
Contributor

Coverage report

St.❔
Category Percentage Covered / Total
🟡 Statements
79.2% (-0.03% 🔻)
13903/17555
🟡 Branches
73.19% (+0.09% 🔼)
6791/9278
🟡 Functions
79.33% (-0.04% 🔻)
3562/4490
🟡 Lines
79.55% (-0.03% 🔻)
13134/16510
Show new covered files 🐣
St.❔
File Statements Branches Functions Lines
🟢
... / admin-as-app.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-mutation.ts
100% 100% 100% 100%
🟢
... / bulk-operation-run-query.ts
100% 100% 100% 100%
🟢
... / get-bulk-operation-by-id.ts
100% 100% 100% 100%
🟢
... / list-bulk-operations.ts
100% 100% 100% 100%
🟢
... / staged-uploads-create.ts
100% 100% 100% 100%
🔴
... / execute.ts
0% 0% 0% 0%
🔴
... / status.ts
0% 0% 0% 0%
🔴
... / pull.ts
0% 100% 0% 0%
🟢
... / execute-operation.ts
92.86% 83.33% 100% 92.31%
🔴
... / pull.ts
0% 0% 0% 0%
🟢
... / bulk-operation-status.ts
96% 90.63% 100% 100%
🟢
... / download-bulk-operation-results.ts
100% 100% 100% 100%
🟢
... / execute-bulk-operation.ts
92.98% 86.84% 100% 92.73%
🟢
... / format-bulk-operation-status.ts
100% 100% 100% 100%
🟢
... / run-mutation.ts
100% 100% 100% 100%
🟢
... / run-query.ts
100% 100% 100% 100%
🟡
... / stage-file.ts
72.73% 62.5% 83.33% 71.88%
🟢
... / watch-bulk-operation.ts
100% 100% 100% 100%
🟢
... / common.ts
95.24% 90% 100% 94.12%
🟢
... / execute-command-helpers.ts
100% 100% 100% 100%
🔴
... / promiseWithResolvers.ts
33.33% 50% 50% 33.33%
Show files with reduced coverage 🔻
St.❔
File Statements Branches Functions Lines
🔴
... / execute.ts
0%
0% (-100% 🔻)
0% 0%
🟢
... / extension-instance.ts
84.8% (+0.23% 🔼)
77.6% (-0.91% 🔻)
92.06% (+0.13% 🔼)
85.11% (+0.24% 🔼)
🟡
... / specification.ts
69.09%
75.61% (+2.44% 🔼)
76.47% (-1.31% 🔻)
68.75%
🟢
... / ui_extension.ts
85.38% (-9.44% 🔻)
72.34% (-8.91% 🔻)
84% (-16% 🔻)
88% (-8.46% 🔻)
🟢
... / developer-platform-client.ts
84.62% (-1.5% 🔻)
73.68% (+3.1% 🔼)
81.82% (+1.82% 🔼)
90.63% (-2.71% 🔻)
🟢
... / api.ts
87.07% (-0.43% 🔻)
76.71% (-0.1% 🔻)
100%
86.49% (-0.43% 🔻)
🟢
... / SingleTask.tsx
84.21% (-15.79% 🔻)
50% (-50% 🔻)
80% (-20% 🔻)
84.21% (-15.79% 🔻)
🔴
... / ui.tsx
50.82% (-0.79% 🔻)
42.86% (-5.53% 🔻)
54.55% (+1.42% 🔼)
50% (-0.82% 🔻)
🟢
... / console.ts
81.82% (+15.15% 🔼)
75% (-25% 🔻)
100% (+33.33% 🔼)
81.82% (+15.15% 🔼)
🔴
... / dev.ts
14.29% (+0.95% 🔼)
3.13% (+0.18% 🔼)
50% (-7.14% 🔻)
14.29% (+0.95% 🔼)
🟢
... / init.ts
88% (-0.89% 🔻)
71.43% (+4.76% 🔼)
86.67% (+4.85% 🔼)
88% (-0.89% 🔻)
🟢
... / storefront-renderer.ts
90.2% (-0.54% 🔻)
78.95%
81.82% (-1.52% 🔻)
90.2% (-0.54% 🔻)
🟡
... / theme-polling.ts
67.12% (-0.93% 🔻)
68.75% 78.57%
66.67% (-0.98% 🔻)

Test suite run success

3484 tests passing in 1406 suites.

Report generated by 🧪jest coverage report action from 24bff60

@nickwesselman
nickwesselman marked this pull request as ready for review December 4, 2025 20:56
@nickwesselman
nickwesselman requested review from a team as code owners December 4, 2025 20:56
@github-actions

This comment has been minimized.

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

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

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20251204205735

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.

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

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

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20251204211708

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.

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

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

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20251204214618

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.

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Dec 4, 2025

Copy link
Copy Markdown
Contributor

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

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20251204220615

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.

Comment thread packages/app/src/cli/flags.ts
Comment thread packages/app/src/cli/services/execute-operation.ts

Copy link
Copy Markdown
Contributor

Thanks for the helper functions. The code seems much cleaner now!

@jordanverasamy jordanverasamy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

not a super thorough look yet, will have to come back to this tomorrow, but from what i see so far, this is really helpful! thanks for going the extra mile on extracting the helpers :) love it!

@gonzaloriestra gonzaloriestra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice idea and refactor! It's working well, I just left a few suggestions

Comment thread packages/app/src/cli/services/dev/fetch.test.ts Outdated
Comment thread packages/app/src/cli/services/dev/fetch.ts Outdated
Comment thread packages/app/src/cli/services/execute-operation.ts
Comment thread packages/app/src/cli/utilities/execute-command-helpers.ts Outdated
Comment thread packages/app/src/cli/services/execute-operation.ts Outdated
Comment thread packages/app/src/cli/services/execute-operation.ts
Comment thread packages/app/src/cli/services/execute-operation.ts

@jordanverasamy jordanverasamy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

left some nits/comments but nothing blocking, this looks fantastic, thanks for putting it together :)

Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions

github-actions Bot commented Dec 5, 2025

Copy link
Copy Markdown
Contributor

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

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20251205201055

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.

@jordanverasamy jordanverasamy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

man, really nice stuff, thanks for accommodating my nits 😂

looks great, excited for this!!

Copy link
Copy Markdown
Contributor Author

I did some extensive e2e testing after these last changes, I think we are in good shape!

@nickwesselman
nickwesselman added this pull request to the merge queue Dec 5, 2025
Merged via the queue into main with commit 23c136c Dec 5, 2025
25 checks passed
@nickwesselman
nickwesselman deleted the shopify_app_execute branch December 5, 2025 23:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants