> For the complete documentation index, see [llms.txt](https://learn.mechanic.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.mechanic.dev/platform/liquid/mechanic-code-snippets.md).

# Mechanic code snippets

A list of convenience snippets provided in the Mechanic code editor.

### `bulk_operation_query` - GraphQL bulk operation query template <a href="#bulk_operation_query" id="bulk_operation_query"></a>

This snippet expands to provide a complete template for initiating a bulk operation query and responding to the results (see [Bulk operations](/core/shopify/bulk-operations.md)). Use it from the top level of a new task after defining the task option fields.

Once the snippet is selected, you will be prompted to select a resource name, which must be in camel case (e.g. `productVariant`). You can type in your own resource name if it doesn't appear in the list. This value will be propagated throughout most of the snippet block.

Hitting `tab` after choosing the initial resource name, you will again be prompted to choose a resource name, this time to be used within the sample JSONL preview block and the resource assignment by `__typename` afterwards. This resource name needs to be in Pascal case to align with Shopify resource identifiers (e.g. `ProductVariant`).

<figure><img src="https://3145272362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQrnkixbmVHvKHMwAbm%2Fuploads%2Fgit-blob-1e255b376752209b98cf493f89c0eece1b14fef9%2F2024-09-06%2016.00.07.gif?alt=media" alt=""><figcaption></figcaption></figure>

***

### `gid` - Shopify global ID <a href="#gid" id="gid"></a>

Expands inline to provide an example [gid](https://shopify.dev/docs/api/usage/gids) with the resource object you choose. You may also type your resource object if there is not a match in the list.

This snippet is most useful when generating stub/preview data for a GraphQL query.

<figure><img src="https://3145272362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQrnkixbmVHvKHMwAbm%2Fuploads%2Fgit-blob-38d964b8677f2716f4b8623b7e3147a9d77ceada%2F2024-09-06%2016.01.34.gif?alt=media" alt=""><figcaption></figcaption></figure>

***

### `object_query` - GraphQL object query <a href="#object_query" id="object_query"></a>

This snippet can be used when you want to query a single top-level resource in GraphQL.

Once the snippet is selected, you will be prompted to select a resource name, which must be in camel case (e.g. `productVariant`). You can type in your own resource name if it doesn't appear in the list. This value will be propagated throughout most of the snippet block.

Hitting `tab` after choosing the initial resource name, you will again be prompted to choose a resource name, this time only for use within the sample preview block. This resource name needs to be in Pascal case to align with Shopify resource identifiers (e.g. `ProductVariant`).

<figure><img src="https://3145272362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQrnkixbmVHvKHMwAbm%2Fuploads%2Fgit-blob-5f34ab70246e01df29b3eb52127097f1594fafd2%2F2024-09-06%2016.02.37.gif?alt=media" alt=""><figcaption></figcaption></figure>

***

### `paginated_query` - GraphQL paginated query <a href="#paginated_query" id="paginated_query"></a>

Use this snippet to provide a paginated query for a resource within a for loop block. It will prompt you to choose the resource type.

<figure><img src="https://3145272362-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MQrnkixbmVHvKHMwAbm%2Fuploads%2Fgit-blob-1249ab98b8b6cc402fe4f9915fa024cac5537111%2F2024-09-06%2016.03.38.gif?alt=media" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://learn.mechanic.dev/platform/liquid/mechanic-code-snippets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
