Implement complete Bulk Operations support for Shopify Admin API #23
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements comprehensive Bulk Operations support for the Shopify Admin API, enabling asynchronous processing of large GraphQL queries and mutations without rate limiting concerns.
Key Features Added
Ruby Module API
ShopifyToolkit::BulkOperations
module with complete functionality:run_bulk_query(query, group_objects: false)
- Submit bulk GraphQL queriesrun_bulk_mutation(mutation, variables_data, ...)
- Submit bulk mutations with automatic staged uploadscurrent_bulk_operation(type: nil)
- Check operation statuscancel_bulk_operation(operation_id)
- Cancel running operationsdownload_results(operation_or_url, parse_results: true)
- Download and parse JSONL resultspoll_until_complete(operation_id, ...)
- Poll with progress callbacksCLI Commands
Five new Thor commands integrated into existing CLI:
shopify-toolkit bulk_query QUERY_FILE
- Submit bulk queriesshopify-toolkit bulk_mutation MUTATION_FILE VARIABLES_FILE
- Submit bulk mutationsshopify-toolkit bulk_status [OPERATION_ID]
- Check operation statusshopify-toolkit bulk_cancel OPERATION_ID
- Cancel operationsshopify-toolkit bulk_results OPERATION_ID_OR_URL
- Download resultsAdvanced Features
stagedUploadsCreate
BulkOperationError
- General bulk operation errorsOperationInProgressError
- When attempting to start while another operation runsExample Usage
# CLI usage shopify-toolkit bulk_query examples/products.graphql --poll --output results.json shopify-toolkit bulk_mutation examples/create_products.graphql examples/variables.json
Implementation Details
AdminClient
module and Thor CLI infrastructureThe implementation supports all bulk operation workflows described in the Shopify documentation, including proper handling of JSONL formats, staged uploads for mutations, and webhook-style polling for completion status.
Fixes #22.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.