GraphQL Admin API in Shopify CLI
If you're developing an app using Shopify CLI, you can execute GraphQL Admin API queries and mutations using the shopify app execute command. You can also use shopify app bulk execute to execute bulk queries and mutations.
These commands use client credentials to authenticate your app against a store in your organization. Their permissions are defined by the access scopes that are available to your app. You should run app execute or app bulk execute from the root of your app directory.
To prevent accidental damage to production data, app execute and app bulk execute limit mutation execution to dev stores.
Anchor to RequirementsRequirements
- You've installed the latest version of Shopify CLI.
- You've configured the necessary access scopes for your query or mutation.
- You've installed the app on the store.
- The app will be installed automatically when using the
shopify app devcommand.
- The app will be installed automatically when using the
Anchor to Querying dataQuerying data
You can use app execute with the --query or --query-file flag to execute a GraphQL query. The command defaults to your last used dev store. You can override this with the --store flag.
Terminal
Anchor to Mutating dataMutating data
You can also use app execute with the --query flag to execute a GraphQL mutation. You can pass GraphQL variables as JSON using the --variables or --variable-file flag.
Terminal
Anchor to Bulk queryingBulk querying
You can use app bulk execute to export data with bulk operations. The query must adhere to the requirements for bulk query operations. Use the --watch flag to automatically poll the bulk operation until it's complete.
Terminal
Anchor to Bulk mutatingBulk mutating
You can use app bulk execute to import data with bulk operations. Use the --variable-file flag to provide the JSONL file for the bulk mutation, or pass the values directly using the --variables flag.
Terminal
Anchor to Checking bulk operation statusChecking bulk operation status
The app bulk status command lists the status of recent bulk operations for your app.
Terminal
You can use the --id flag to check the status of a specific bulk operation.
Terminal
Anchor to Canceling bulk operationsCanceling bulk operations
The app bulk cancel command cancels a running bulk operation. You must provide the operation ID using the --id flag.
Terminal
Anchor to Next stepsNext steps
- Review the command reference for
app executeandapp bulk execute. - Review the command reference for
app bulk statusandapp bulk cancel. - Learn more about bulk queries and bulk mutations.