\\\ mutation after creation.
***
Collections can be displayed in a store with Shopify's theme system through [Liquid templates](https://shopify.dev/docs/storefronts/themes/architecture/templates/collection) and can be customized with [template suffixes](https://shopify.dev/docs/storefronts/themes/architecture/templates/alternate-templates) for unique layouts. They also support advanced features like translated content, resource feedback, and contextual publication for location-based catalogs.
Learn about [using metafields with smart collections](https://shopify.dev/docs/apps/build/custom-data/metafields/use-metafield-capabilities).
* activeOperations
[CollectionOperations!](https://shopify.dev/docs/api/admin-graphql/latest/objects/CollectionOperations)
non-null
Collection duplicate operations involving this collection, either as a source (copying products from this collection to another) or a target (copying products to this collection from another).
* availablePublicationsCount
[Count](https://shopify.dev/docs/api/admin-graphql/latest/objects/Count)
The number of [publications](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication) that a resource is published to, without [feedback errors](https://shopify.dev/docs/api/admin-graphql/latest/objects/ResourceFeedback).
* description
[String!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String)
non-null
A single-line, text-only description of the collection, stripped of any HTML tags and formatting that were included in the description.
* truncateAt
[Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int)
### Arguments
Truncates a string after the given length.
***
* descriptionHtml
[HTML!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/HTML)
non-null
The description of the collection, including any HTML tags and formatting. This content is typically displayed to customers, such as on an online store, depending on the theme.
* events
[EventConnection!](https://shopify.dev/docs/api/admin-graphql/latest/connections/EventConnection)
non-null
The paginated list of events associated with the host subject.
* first
[Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int)
### Arguments
The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql).
* after
[String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String)
The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql).
* last
[Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int)
The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql).
* before
[String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String)
The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql).
* reverse
[Boolean](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Boolean)
Default:false
Reverse the order of the underlying list.
* sortKey
[EventSortKeys](https://shopify.dev/docs/api/admin-graphql/latest/enums/EventSortKeys)
Default:ID
Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations).
* query
[String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String)
A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax).
* * action
string
* comments
boolean
* created\_at
time
* id
id
* subject\_type
string
- The action that occured.
- Example:
* `action:create`
Whether or not to include [comment-events](https://shopify.dev/api/admin-graphql/latest/objects/CommentEvent) in your search, passing `false` will exclude comment-events, any other value will include comment-events.
- Example:
* `false`
* `true`
Filter by the date and time when the event occurred. Event data is retained for 1 year.
- Example:
* `created_at:>2025-10-21`
* `created_at:The best selling ipod ever
", "updatedAt": "2008-02-02T00:00:00Z", "sortOrder": "MANUAL", "image": { "url": "https://cdn.shopify.com/s/files/1/0005/4838/0009/collections/ipod_nano_8gb.jpg?v=1750460312", "height": 456, "width": 123 } } } ``` * ### Retrieve a collection with its products #### Description Retrieve a \[collection]\(https://shopify.dev/docs/api/admin-graphql/latest/objects/Collection) along with a list of its associated \[products]\(https://shopify.dev/docs/api/admin-graphql/latest/objects/Product). The response includes the collection details and the first 10 products in the collection, with each product's ID and title. This is useful for displaying a collection page with its product listings. #### Query ```graphql query GetCollectionWithProducts($id: ID!) { collection(id: $id) { id title handle descriptionHtml products(first: 10) { nodes { id title handle } pageInfo { hasNextPage hasPreviousPage } } } } ``` #### Variables ```json { "id": "gid://shopify/Collection/841564295" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query GetCollectionWithProducts($id: ID!) { collection(id: $id) { id title handle descriptionHtml products(first: 10) { nodes { id title handle } pageInfo { hasNextPage hasPreviousPage } } } }", "variables": { "id": "gid://shopify/Collection/841564295" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query GetCollectionWithProducts($id: ID!) { collection(id: $id) { id title handle descriptionHtml products(first: 10) { nodes { id title handle } pageInfo { hasNextPage hasPreviousPage } } } }`, { variables: { "id": "gid://shopify/Collection/841564295" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query GetCollectionWithProducts($id: ID!) { collection(id: $id) { id title handle descriptionHtml products(first: 10) { nodes { id title handle } pageInfo { hasNextPage hasPreviousPage } } } } QUERY variables = { "id": "gid://shopify/Collection/841564295" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query GetCollectionWithProducts($id: ID!) { collection(id: $id) { id title handle descriptionHtml products(first: 10) { nodes { id title handle } pageInfo { hasNextPage hasPreviousPage } } } }`, "variables": { "id": "gid://shopify/Collection/841564295" }, }, }); ``` #### Shopify CLI ```bash shopify app execute \ --query \ 'query GetCollectionWithProducts($id: ID!) { collection(id: $id) { id title handle descriptionHtml products(first: 10) { nodes { id title handle } pageInfo { hasNextPage hasPreviousPage } } } }' \ --variables \ '{ "id": "gid://shopify/Collection/841564295" }' ``` #### Response ```json { "collection": { "id": "gid://shopify/Collection/841564295", "title": "IPods", "handle": "ipods", "descriptionHtml": "The best selling ipod ever
", "products": { "nodes": [ { "id": "gid://shopify/Product/632910392", "title": "IPod Nano - 8GB", "handle": "ipod-nano" } ], "pageInfo": { "hasNextPage": false, "hasPreviousPage": false } } } } ``` * ### Retrieve a smart collection with its rules #### Description Retrieve a \[smart collection]\(https://help.shopify.com/manual/products/collections/smart-collections) along with its automated \[rules]\(https://help.shopify.com/manual/products/collections/smart-collections/conditions). Smart collections automatically include products that match specific conditions. The response includes the collection details and its rule set, which defines the conditions used to automatically populate the collection with products. #### Query ```graphql query GetSmartCollection($id: ID!) { collection(id: $id) { id title handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } products(first: 5) { nodes { id title } } } } ``` #### Variables ```json { "id": "gid://shopify/Collection/482865238" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query GetSmartCollection($id: ID!) { collection(id: $id) { id title handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } products(first: 5) { nodes { id title } } } }", "variables": { "id": "gid://shopify/Collection/482865238" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query GetSmartCollection($id: ID!) { collection(id: $id) { id title handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } products(first: 5) { nodes { id title } } } }`, { variables: { "id": "gid://shopify/Collection/482865238" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query GetSmartCollection($id: ID!) { collection(id: $id) { id title handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } products(first: 5) { nodes { id title } } } } QUERY variables = { "id": "gid://shopify/Collection/482865238" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query GetSmartCollection($id: ID!) { collection(id: $id) { id title handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } products(first: 5) { nodes { id title } } } }`, "variables": { "id": "gid://shopify/Collection/482865238" }, }, }); ``` #### Shopify CLI ```bash shopify app execute \ --query \ 'query GetSmartCollection($id: ID!) { collection(id: $id) { id title handle sortOrder ruleSet { appliedDisjunctively rules { column relation condition } } products(first: 5) { nodes { id title } } } }' \ --variables \ '{ "id": "gid://shopify/Collection/482865238" }' ``` #### Response ```json { "collection": { "id": "gid://shopify/Collection/482865238", "title": "Smart iPods", "handle": "smart-ipods", "sortOrder": "MANUAL", "ruleSet": { "appliedDisjunctively": false, "rules": [ { "column": "TYPE", "relation": "EQUALS", "condition": "Cult Products" } ] }, "products": { "nodes": [ { "id": "gid://shopify/Product/632910392", "title": "IPod Nano - 8GB" }, { "id": "gid://shopify/Product/921728736", "title": "IPod Touch 8GB" } ] } } } ``` * ### Retrieve a collection's publication status #### Description Check if a collection is published to a \[sales channel]\(https://shopify.dev/docs/apps/build/sales-channels). The response includes publication status and publication-related fields. This is useful for determining collection visibility and managing which collections are available through your app. > Note: > You must have the \`read\_product\_listings\` access scope to retrieve publication information. #### Query ```graphql query GetCollectionPublicationStatus($id: ID!) { collection(id: $id) { id title publishedOnCurrentPublication publicationCount resourcePublicationsCount { count precision } } } ``` #### Variables ```json { "id": "gid://shopify/Collection/841564295" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query GetCollectionPublicationStatus($id: ID!) { collection(id: $id) { id title publishedOnCurrentPublication publicationCount resourcePublicationsCount { count precision } } }", "variables": { "id": "gid://shopify/Collection/841564295" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query GetCollectionPublicationStatus($id: ID!) { collection(id: $id) { id title publishedOnCurrentPublication publicationCount resourcePublicationsCount { count precision } } }`, { variables: { "id": "gid://shopify/Collection/841564295" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query GetCollectionPublicationStatus($id: ID!) { collection(id: $id) { id title publishedOnCurrentPublication publicationCount resourcePublicationsCount { count precision } } } QUERY variables = { "id": "gid://shopify/Collection/841564295" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query GetCollectionPublicationStatus($id: ID!) { collection(id: $id) { id title publishedOnCurrentPublication publicationCount resourcePublicationsCount { count precision } } }`, "variables": { "id": "gid://shopify/Collection/841564295" }, }, }); ``` #### Shopify CLI ```bash shopify app execute \ --query \ 'query GetCollectionPublicationStatus($id: ID!) { collection(id: $id) { id title publishedOnCurrentPublication publicationCount resourcePublicationsCount { count precision } } }' \ --variables \ '{ "id": "gid://shopify/Collection/841564295" }' ``` #### Response ```json { "collection": { "id": "gid://shopify/Collection/841564295", "title": "IPods", "publishedOnCurrentPublication": true, "publicationCount": 2, "resourcePublicationsCount": { "count": 2, "precision": "EXACT" } } } ``` * ### Try retrieving a non-existent collection #### Description Attempting to retrieve a collection that doesn't exist returns \`null\`. This demonstrates the expected behavior when querying for a non-existent collection ID. #### Query ```graphql query GetNonExistentCollection($id: ID!) { collection(id: $id) { id title handle } } ``` #### Variables ```json { "id": "gid://shopify/Collection/-1" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2026-01/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query GetNonExistentCollection($id: ID!) { collection(id: $id) { id title handle } }", "variables": { "id": "gid://shopify/Collection/-1" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query GetNonExistentCollection($id: ID!) { collection(id: $id) { id title handle } }`, { variables: { "id": "gid://shopify/Collection/-1" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query GetNonExistentCollection($id: ID!) { collection(id: $id) { id title handle } } QUERY variables = { "id": "gid://shopify/Collection/-1" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query GetNonExistentCollection($id: ID!) { collection(id: $id) { id title handle } }`, "variables": { "id": "gid://shopify/Collection/-1" }, }, }); ``` #### Shopify CLI ```bash shopify app execute \ --query \ 'query GetNonExistentCollection($id: ID!) { collection(id: $id) { id title handle } }' \ --variables \ '{ "id": "gid://shopify/Collection/-1" }' ``` #### Response ```json { "collection": null } ```