--- title: GraphQL Admin API in Shopify CLI description: Execute GraphQL Admin API queries and mutations in Shopify CLI. api_name: usage source_url: html: 'https://shopify.dev/docs/api/usage/api-exploration/admin-cli-app-execute' md: 'https://shopify.dev/docs/api/usage/api-exploration/admin-cli-app-execute.md' --- # GraphQL Admin API in Shopify CLI If you're developing an app using [Shopify CLI](https://shopify.dev/docs/apps/build/cli-for-apps), you can execute GraphQL Admin API queries and mutations using the [`shopify app execute`](https://shopify.dev/docs/api/shopify-cli/app/app-execute) command. You can also use [`shopify app bulk execute`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-execute) to execute bulk [queries](https://shopify.dev/docs/api/usage/bulk-operations/queries) and [mutations](https://shopify.dev/docs/api/usage/bulk-operations/imports). These commands use [client credentials](https://shopify.dev/docs/apps/build/authentication-authorization/access-tokens/client-credentials-grant) to authenticate your app against a store in your organization. Their permissions are defined by the [access scopes](https://shopify.dev/docs/api/usage/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](https://shopify.dev/docs/apps/build/cli-for-apps/app-configuration#dev-stores). *** ## Requirements * You've installed the [latest version of Shopify CLI](https://shopify.dev/docs/api/shopify-cli#upgrade). * You've [configured](https://shopify.dev/docs/apps/build/authentication-authorization/app-installation/manage-access-scopes) 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 dev` command](https://shopify.dev/docs/apps/build/cli-for-apps/test-apps-locally). *** ## Querying 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 ```bash shopify app execute --query '{ products(first: 3) { edges { node { id title } } } }' ``` *** ## Mutating 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 ```bash shopify app execute --query \ 'mutation productSet($identifier: ProductSetIdentifiers, $input: ProductSetInput!) { productSet(identifier: $identifier, input: $input) { product { id } userErrors { field message } } }' \ --variables \ '{ "identifier": { "handle": "my-cli-product" }, "input": { "handle": "my-cli-product", "title": "Simple Product (Single Variant)", "descriptionHtml": "
Product with a single variant, used to set price and SKU.
", "status": "ACTIVE", "productOptions": [ { "name": "Title", "values": [ { "name": "Default Title" } ] } ], "variants": [ { "optionValues": [ { "optionName": "Title", "name": "Default Title" } ], "price": 12.99, "sku": "SIMPLE-001" } ] } }' ``` *** ## Bulk querying You can use `app bulk execute` to [export data with bulk operations](https://shopify.dev/docs/api/usage/bulk-operations/queries). The query must adhere to the [requirements](https://shopify.dev/docs/api/usage/bulk-operations/queries#operation-restrictions) for bulk query operations. Use the `--watch` flag to automatically poll the bulk operation until it's complete. ## Terminal ```bash shopify app bulk execute --watch --query '{ products { edges { node { id title variants { edges { node { id sku price } } } } } } }' ``` *** ## Bulk mutating You can use `app bulk execute` to [import data with bulk operations](https://shopify.dev/docs/api/usage/bulk-operations/imports). Use the `--variable-file` flag to provide the [JSONL file](https://shopify.dev/docs/api/usage/bulk-operations/imports#create-a-jsonl-file-and-include-graphql-variables) for the bulk mutation, or pass the values directly using the `--variables` flag. ## Terminal ```bash cat <