---
title: GraphQL Admin API in Shopify CLI
description: Execute GraphQL Admin API queries and mutations in Shopify CLI.
source_url:
  html: >-
    https://shopify.dev/docs/apps/build/apis/graphql-admin/api-exploration/admin-cli-app-execute
  md: >-
    https://shopify.dev/docs/apps/build/apis/graphql-admin/api-exploration/admin-cli-app-execute.md
---

# Graph​QL 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/apps/build/apis/graphql-admin/bulk-operations/queries) and [mutations](https://shopify.dev/docs/apps/build/apis/graphql-admin/bulk-operations/imports).

These commands use [client credentials](https://shopify.dev/docs/apps/build/authentication-authorization/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/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": "<p>Product with a single variant, used to set price and SKU.</p>",
        "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/apps/build/apis/graphql-admin/bulk-operations/queries). The query must adhere to the [requirements](https://shopify.dev/docs/apps/build/apis/graphql-admin/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/apps/build/apis/graphql-admin/bulk-operations/imports). Use the `--variable-file` flag to provide the [JSONL file](https://shopify.dev/docs/apps/build/apis/graphql-admin/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 <<EOF > products.jsonl
{ "input": { "title": "Sweet new snowboard 1", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 2", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 3", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 4", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 5", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 6", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 7", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 8", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 9", "productType": "Snowboard", "vendor": "JadedPixel" } }
{ "input": { "title": "Sweet new snowboard 10", "productType": "Snowboard", "vendor": "JadedPixel" } }
EOF
shopify app bulk execute --watch --variable-file products.jsonl --query \
  'mutation productCreate($input: ProductInput!) {
    productCreate(input: $input) {
      product {
        id
        title
        variants(first: 10) {
          edges {
            node {
              id
              title
              inventoryQuantity
            }
          }
        }
      }
      userErrors {
        message
        field
      }
    }
  }'
```

***

## Checking bulk operation status

The [`app bulk status`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-status) command lists the status of recent bulk operations for your app.

## Terminal

```bash
shopify app bulk status
```

You can use the `--id` flag to check the status of a specific bulk operation.

## Terminal

```bash
shopify app bulk status --id 1234567890
```

***

## Canceling bulk operations

The [`app bulk cancel`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-cancel) command cancels a running bulk operation. You must provide the operation ID using the `--id` flag.

## Terminal

```bash
shopify app bulk cancel --id 1234567890
```

***

## Next steps

* Review the command reference for [`app execute`](https://shopify.dev/docs/api/shopify-cli/app/app-execute) and [`app bulk execute`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-execute).
* Review the command reference for [`app bulk status`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-status) and [`app bulk cancel`](https://shopify.dev/docs/api/shopify-cli/app/app-bulk-cancel).
* Learn more about [bulk queries](https://shopify.dev/docs/apps/build/apis/graphql-admin/bulk-operations/queries) and [bulk mutations](https://shopify.dev/docs/apps/build/apis/graphql-admin/bulk-operations/imports).

***
