collection
Returns a Collection resource by ID.
Arguments
- •ID!required
The ID of the
Collection
to return.
Anchor to Possible returnsPossible returns
- Anchor to CollectionCollection•
Represents a group of products that can be displayed in online stores and other sales channels in categories, which makes it easy for customers to find them. For example, an athletics store might create different collections for running attire, shoes, and accessories.
Collections can be defined by conditions, such as whether they match certain product tags. These are called smart or automated collections.
Collections can also be created for a custom group of products. These are called custom or manual collections.
- Get a collection by ID
- Get a metafield attached to a collection
- Get metafields attached to a collection
- Get pinned metafield definitions associated with a collection
- Retrieve product_ids that are published to a collection_id
- Retrieve a list of products belonging to a collection
- Retrieve a specific collection listing that is published to your app
- Retrieves a count of collects
- Retrieves a single collection
- Retrieves a single custom collection
- Retrieves a single smart collection
- Returns null when collection is not found
Examples
query {
collection(id: "gid://shopify/Collection/841564295") {
id
title
handle
updatedAt
}
}
curl -X POST \
https://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \
-H 'Content-Type: application/json' \
-H 'X-Shopify-Access-Token: {access_token}' \
-d '{
"query": "query { collection(id: \"gid://shopify/Collection/841564295\") { id title handle updatedAt } }"
}'
const { admin } = await authenticate.admin(request);
const response = await admin.graphql(
`#graphql
query {
collection(id: "gid://shopify/Collection/841564295") {
id
title
handle
updatedAt
}
}`,
);
const data = await response.json();
const client = new shopify.clients.Graphql({session});
const data = await client.query({
data: `query {
collection(id: "gid://shopify/Collection/841564295") {
id
title
handle
updatedAt
}
}`,
});
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 {
collection(id: "gid://shopify/Collection/841564295") {
id
title
handle
updatedAt
}
}
QUERY
response = client.query(query: query)