Skip to content

Conversation

@ericlee878
Copy link
Contributor

@ericlee878 ericlee878 commented Nov 8, 2025

Link to ticket

Summary
This PR lays the groundwork for the shopify app execute command in the Shopify CLI. It creates the minimal foundations of the BulkOps CLI that future PRs will build upon. By minimal foundations, we implemented just the query (not mutation), asynchronous CLI command (no synchronous progress bar), output to STDOUT (no output file). We just wanted the skeleton of the CLI command, so that future PRs could work on extending different parts of this command in parallel.

Implementation Details

  • The packages/app/src/cli/commands/app/execute.ts file runs the main command. It calls on other service files.
  • The packages/app/src/cli/api/graphql/admin-bulk-operations.ts file is a service file that stores the queries and data structures. For mutations in the future, we should add their respective queries and data structures here.
  • The packages/app/src/cli/services/bulk-operation-run-query.ts file holds the query-specific function that holds the logic that calls the BulkOperation Query API.

GraphQL Codegen Setup for Bulk Operations

Added GraphQL code generation configuration for the bulk-operations API to enable type-safe GraphQL operations.

Changes:

  • Added bulkOperations project to graphql.config.ts pointing to admin_schema.graphql
  • Added corresponding codegen tasks to packages/app/project.json
  • Run pnpm graphql-codegen to generate TypeScript types from GraphQL queries/mutations

This codegen allows us to have a type-safe GraphQL operations with compile-time checks that could be automatically regenerated if we change the GraphQL API.

Testing

  1. Follow the instructions here to setup a test app
  2. Go here and create a store (if not already have one).
  3. Use the command pnpm shopify app execute --path=<path to test app> --query="{products{edges{node{id title handle}}}}"
  4. Get the BulkOps id that is returned and run this query in Services Internal.
SELECT * from bulk_operations where id = <gid>;

Yours should pop up. Mine was in shard 239 (for reference).

Unit tests were not added for the execute-bulk-operation.ts file yet because the task it was doing is currently very trivial. The main functionality of this file will come when the mutations are implemented (next PR coming!) so I will add unit tests for this file then.

Copy link
Contributor Author

ericlee878 commented Nov 8, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@ericlee878 ericlee878 changed the title app connection setup step 1 Connect app in BulkOperation CLI to BulkOperation API Nov 8, 2025
@ericlee878 ericlee878 changed the title Connect app in BulkOperation CLI to BulkOperation API Initial Setup: Bulk Operations Infrastructure for Shopify CLI Nov 8, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 8, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
79.24% (+0.01% 🔼)
13601/17165
🟡 Branches
73.13% (+0.02% 🔼)
6637/9076
🟡 Functions
79.37% (-0% 🔻)
3508/4420
🟡 Lines
79.59% (+0.01% 🔼)
12846/16140
Show new covered files 🐣
St.
File Statements Branches Functions Lines
🟢
... / bulk-operation-run-query.ts
100% 100% 100% 100%
🟢
... / execute-bulk-operation.ts
100% 83.33% 100% 100%
🟢
... / run-query.ts
100% 100% 100% 100%

Test suite run success

3359 tests passing in 1376 suites.

Report generated by 🧪jest coverage report action from 3784bae

@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch 2 times, most recently from b8f02df to 747c9e6 Compare November 8, 2025 01:31
@jordanverasamy jordanverasamy force-pushed the 11-07-implement_simple_bulk_query branch from 3879d74 to efc1388 Compare November 10, 2025 18:13
@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch 3 times, most recently from 70c6f47 to 446c3cf Compare November 10, 2025 20:24
@ericlee878 ericlee878 marked this pull request as ready for review November 10, 2025 20:27
@ericlee878 ericlee878 requested review from a team as code owners November 10, 2025 20:27
@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.

@ericlee878
Copy link
Contributor Author

@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch 4 times, most recently from 2ef312a to f813e73 Compare November 12, 2025 23:04
@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch from 4024e20 to a6645ff Compare November 13, 2025 00:58
…k-operations directory in services directory
@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch from a6645ff to 3784bae Compare November 13, 2025 01:09
@jordanverasamy jordanverasamy force-pushed the 11-07-implement_simple_bulk_query branch from 3784bae to 2b6b260 Compare November 13, 2025 18:19
@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch from 2b6b260 to 3784bae Compare November 14, 2025 00:26
@jordanverasamy jordanverasamy force-pushed the 11-07-implement_simple_bulk_query branch from 3784bae to 2b6b260 Compare November 14, 2025 00:35
@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch from 2b6b260 to 3784bae Compare November 14, 2025 00:54
@jordanverasamy jordanverasamy force-pushed the 11-07-implement_simple_bulk_query branch from 3784bae to 2b6b260 Compare November 14, 2025 01:19
@ericlee878 ericlee878 force-pushed the 11-07-implement_simple_bulk_query branch from 2b6b260 to 3784bae Compare November 14, 2025 07:27
Comment on lines +39 to +44
query: Flags.string({
char: 'q',
description: 'The GraphQL query, as a string.',
env: 'SHOPIFY_FLAG_QUERY',
required: true,
}),
Copy link
Contributor

@isaacroldan isaacroldan Nov 14, 2025

Choose a reason for hiding this comment

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

Would be nice if this query can also be passed as standard input, so that you can do:

shopify app execute --query 'your query' 
// or
echo 'your query' | shopify app execute
// or
cat query.txt | shopify app execute

the last one, being able to run a query from a file is super useful for this case where queries can be complex!

This is the same pattern that shopify app function run uses.
That would mean this flag is not required and you will need to validate manually that either the flag or stdin are present.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a good idea to me. @nickwesselman One thing - would we still need a separate --variable-file flag with this?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is definitely a good idea, we should align with @nickwesselman on which pattern to follow. I'd argue that we can keep this out of scope for this PR though, and just make a ticket to improve this in a followup?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah for sure, I like this in function run and it's a nice one-liner approach for simple queries. Let's log this as a follow up.

Copy link
Contributor Author

@ericlee878 ericlee878 Nov 14, 2025

Choose a reason for hiding this comment

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

Ticket created for this

Comment on lines +39 to +40
const result = bulkOperationResponse?.bulkOperation
if (result) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we show a specific error if there is no result here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Future ticket

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