How markwkiehl/medium_shopify_graphql_bulk_query works
Project type and purpose
• This is a small open-source utility (two Python scripts) that demonstrates how to perform Shopify GraphQL Bulk Queries to fetch and update product variants.
• It’s not a multi-tier web app but a command-line client interacting with Shopify’s GraphQL Bulk API.
File structure
• Top level contains only two Python scripts:
• shopify_graphql_bulk_query_product_variants.py (bulk fetch)
• shopify_graphql_bulk_query_update_product_variants.py (bulk update)
• No additional modules or directories—both scripts run standalone.
• No local database or web server components.
README for additional insights
• The README simply describes the usage scenario (Medium article, example code).
• The focus is on showing “how to perform Shopify GraphQL bulk query.”
Main components
a. Client Environment
• Python runtime (interpreter)
• Local file system (for temporary CSV or JSON output)
b. Bulk-Query Fetcher
• The “product_variants” script
• Issues a bulk GraphQL query (mutation) to Shopify
• Receives a bulk operation ID
• Polls the GraphQL endpoint for completion
• Downloads the result (CSV or JSON)
• Parses and writes to local file
c. Bulk-Query Updater
• The “update_product_variants” script
• Loads local data or constructs update payload
• Issues a bulk mutation to Shopify to update variants
• Polls for job completion
• Logs success/failure
d. External Service
• Shopify GraphQL Bulk API endpoint
– /graphql.json for initiating bulk query
– JobStatus endpoint for polling
– Result URL for download
Relationships and data flow
1. “Start bulk query” → Shopify
2. “Poll for status” ↔ Shopify
3. “Download result” ← Shopify
Architectural patterns and design principles
• Client–Server pattern: Python client ←→ Shopify server
• Polling pattern for long-running bulk operations
• Separation of concerns: fetcher vs. updater
• Idempotent bulk operations (using job IDs)
Key technologies and libraries
• Python 3.x
• “requests” for HTTP
• “json” or “csv” for parsing
• Shopify GraphQL Bulk API
• Component labels: “Fetch Script,” “Update Script,” “Local File Store,” “Shopify GraphQL API”
Emphasize
• Be exhaustive—break the script logic into sub-steps (initiate, poll, download, parse, send update)
• Lifecycle of a bulk job
• Dependencies (scripts depend on requests, JSON, file IO, and network connectivity)