-
Notifications
You must be signed in to change notification settings - Fork 224
Initial Setup: Bulk Operations Infrastructure for Shopify CLI #6588
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
Coverage report
Show new covered files 🐣
Test suite run success3359 tests passing in 1376 suites. Report generated by 🧪jest coverage report action from 3784bae |
b8f02df to
747c9e6
Compare
3879d74 to
efc1388
Compare
70c6f47 to
446c3cf
Compare
|
We detected some changes at Caution DO NOT create changesets for features which you do not wish to be included in the public changelog of the next CLI release. |
446c3cf to
9e9ebed
Compare
9e9ebed to
446c3cf
Compare
3eef16f to
e0c10b0
Compare
2ef312a to
f813e73
Compare
4024e20 to
a6645ff
Compare
…k-operations directory in services directory
a6645ff to
3784bae
Compare
3784bae to
2b6b260
Compare
2b6b260 to
3784bae
Compare
3784bae to
2b6b260
Compare
2b6b260 to
3784bae
Compare
3784bae to
2b6b260
Compare
2b6b260 to
3784bae
Compare
| query: Flags.string({ | ||
| char: 'q', | ||
| description: 'The GraphQL query, as a string.', | ||
| env: 'SHOPIFY_FLAG_QUERY', | ||
| required: true, | ||
| }), |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ticket created for this
| const result = bulkOperationResponse?.bulkOperation | ||
| if (result) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Future ticket

Link to ticket
Summary
This PR lays the groundwork for the
shopify app executecommand 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
packages/app/src/cli/commands/app/execute.tsfile runs the main command. It calls on other service files.packages/app/src/cli/api/graphql/admin-bulk-operations.tsfile 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.packages/app/src/cli/services/bulk-operation-run-query.tsfile 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:
graphql.config.tspointing toadmin_schema.graphqlpnpm graphql-codegento generate TypeScript types from GraphQL queries/mutationsThis 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
pnpm shopify app execute --path=<path to test app> --query="{products{edges{node{id title handle}}}}"Yours should pop up. Mine was in shard 239 (for reference).
Unit tests were not added for the
execute-bulk-operation.tsfile 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.