Skip to content

Conversation

@nickwesselman
Copy link
Contributor

@nickwesselman nickwesselman commented Dec 18, 2025

WHY are these changes introduced?

Writing example scripts with app execute and app bulk execute made it clear that an argument for this would make the code cleaner and intent more obvious.

WHAT is this pull request doing?

Adds a new --query-file flag to the app execute and app bulk execute commands that allows loading GraphQL queries from a file.

Key changes:

  • Added a new --query-file flag to both operation and bulk operation commands
  • Made --query and --query-file flags mutually exclusive
  • Updated error messages to include the new option
  • Added tests to verify the new functionality
  • Updated the command helper to read from the file when the flag is provided

How to test your changes?

  1. Create a file containing a GraphQL query, e.g., query.graphql
{ shop { name } }
  1. Run shopify app execute --query-file query.graphql
  2. Verify the query executes correctly
  3. Try using both --query and --query-file together and confirm it fails
  4. Try using a non-existent file path and verify the error message is helpful

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

Checklist

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

Copy link
Contributor Author

nickwesselman commented Dec 18, 2025

@nickwesselman nickwesselman changed the title add support for --query-file to both app execute and app bulk execute Add --query-file flag to app execute and app bulk execute for loading GraphQL queries from files Dec 18, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 18, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 79.52% 14196/17853
🟡 Branches 73.62% 6968/9465
🟡 Functions 79.63% 3640/4571
🟡 Lines 79.89% 13422/16801

Test suite run success

3570 tests passing in 1416 suites.

Report generated by 🧪jest coverage report action from 1ffab0d

@nickwesselman nickwesselman marked this pull request as ready for review December 18, 2025 14:20
@nickwesselman nickwesselman requested review from a team as code owners December 18, 2025 14:20
@github-actions
Copy link
Contributor

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.

Comment on lines +69 to +71
if (flags.query) {
query = flags.query
} else if (flags['query-file']) {

Choose a reason for hiding this comment

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

what if a user submits both?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OCLIF should prevent that based on the flag config

/**
* Validates bulk operation-specific constraints for variables.
*/
function validateBulkOperationVariables(graphqlOperation: string, variablesJsonl?: string): void {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm assuming this means that normal (non-bulk) GraphQL queries can have variables?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, this is only invoked for bulk operations

Copy link
Contributor

@gonzaloriestra gonzaloriestra left a comment

Choose a reason for hiding this comment

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

👏

Base automatically changed from app_execute_variable_file to main December 19, 2025 18:10
@nickwesselman nickwesselman added this pull request to the merge queue Dec 19, 2025
Merged via the queue into main with commit a28e8f4 Dec 19, 2025
36 of 43 checks passed
@nickwesselman nickwesselman deleted the app_execute_query_file branch December 19, 2025 18:18
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.

6 participants