# collection - admin-graphql - QUERY
Version: 2024-10
## Description
Returns a Collection resource by ID.
### Access Scopes
## Arguments
* [id](/docs/api/admin-graphql/2024-10/scalars/ID): ID! - The ID of the `Collection` to return.
## Returns
* [availablePublicationsCount](/docs/api/admin-graphql/2024-10/objects/Count): 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](/docs/api/admin-graphql/2024-10/scalars/String): String! A single-line, text-only description of the collection, stripped of any HTML tags and formatting that were included in the description.
* [descriptionHtml](/docs/api/admin-graphql/2024-10/scalars/HTML): HTML! 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.
* [feedback](/docs/api/admin-graphql/2024-10/objects/ResourceFeedback): ResourceFeedback Information about the collection that's provided through resource feedback.
* [handle](/docs/api/admin-graphql/2024-10/scalars/String): String! A unique string that identifies the collection. If a handle isn't specified when a collection is created, it's automatically generated from the collection's original title, and typically includes words from the title separated by hyphens. For example, a collection that was created with the title `Summer Catalog 2022` might have the handle `summer-catalog-2022`.
If the title is changed, the handle doesn't automatically change.
The handle can be used in themes by the Liquid templating language to refer to the collection, but using the ID is preferred because it never changes.
* [hasProduct](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! Whether the collection includes the specified product.
* [id](/docs/api/admin-graphql/2024-10/scalars/ID): ID! A globally-unique ID.
* [image](/docs/api/admin-graphql/2024-10/objects/Image): Image The image associated with the collection.
* [legacyResourceId](/docs/api/admin-graphql/2024-10/scalars/UnsignedInt64): UnsignedInt64! The ID of the corresponding resource in the REST Admin API.
* [metafield](/docs/api/admin-graphql/2024-10/objects/Metafield): Metafield A [custom field](https://shopify.dev/docs/apps/build/custom-data),
including its `namespace` and `key`, that's associated with a Shopify resource
for the purposes of adding and storing additional information.
* [privateMetafield](/docs/api/admin-graphql/2024-10/objects/PrivateMetafield): PrivateMetafield Returns a private metafield by namespace and key that belongs to the resource.
* [productsCount](/docs/api/admin-graphql/2024-10/objects/Count): Count The number of products in the collection.
* [publicationCount](/docs/api/admin-graphql/2024-10/scalars/Int): Int! 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).
* [publishedOnChannel](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! Whether the resource is published to a specific channel.
* [publishedOnCurrentChannel](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! Whether the resource is published to a
[channel](https://shopify.dev/docs/api/admin-graphql/latest/objects/Channel).
For example, the resource might be published to the online store channel.
* [publishedOnCurrentPublication](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! Whether the resource is published to the app's
[publication](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication).
For example, the resource might be published to the app's online store channel.
* [publishedOnPublication](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! Whether the resource is published to a specified
[publication](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication).
* [resourcePublicationsCount](/docs/api/admin-graphql/2024-10/objects/Count): 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).
* [ruleSet](/docs/api/admin-graphql/2024-10/objects/CollectionRuleSet): CollectionRuleSet For a smart (automated) collection, specifies the rules that determine whether a product is included.
* [seo](/docs/api/admin-graphql/2024-10/objects/SEO): SEO! If the default SEO fields for page title and description have been modified, contains the modified information.
* [sortOrder](/docs/api/admin-graphql/2024-10/enums/CollectionSortOrder): CollectionSortOrder! The order in which the products in the collection are displayed by default in the Shopify admin and in sales channels, such as an online store.
* [storefrontId](/docs/api/admin-graphql/2024-10/scalars/StorefrontID): StorefrontID! The Storefront GraphQL API ID of the `Collection`.
As of the `2022-04` version release, the Storefront GraphQL API will no longer return Base64 encoded IDs to match the behavior of the Admin GraphQL API. Therefore, you can safely use the `id` field's value instead.
* [templateSuffix](/docs/api/admin-graphql/2024-10/scalars/String): String The suffix of the Liquid template being used to show the collection in an online store. For example, if the value is `custom`, then the collection is using the `collection.custom.liquid` template. If the value is `null`, then the collection is using the default `collection.liquid` template.
* [title](/docs/api/admin-graphql/2024-10/scalars/String): String! The name of the collection. It's displayed in the Shopify admin and is typically displayed in sales channels, such as an online store.
* [translations](/docs/api/admin-graphql/2024-10/objects/Translation): Translation! The published translations associated with the resource.
* [updatedAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime! The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) when the collection was last modified.
## Examples
### Get a collection by ID
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collection(id: \\\"gid://shopify/Collection/841564295\\\") { id title handle updatedAt } }\"\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collection(id: \"gid://shopify/Collection/841564295\") {\n id\n title\n handle\n updatedAt\n }\n }`,\n});\n"
Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collection(id: \"gid://shopify/Collection/841564295\") {\n id\n title\n handle\n updatedAt\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n"
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collection(id: \"gid://shopify/Collection/841564295\") {\n id\n title\n handle\n updatedAt\n }\n }`,\n);\n\nconst data = await response.json();\n"
Graphql query: "query {\n collection(id: \"gid://shopify/Collection/841564295\") {\n id\n title\n handle\n updatedAt\n }\n}"
#### Graphql Input
null
#### Graphql Response
{
"data": {
"collection": {
"id": "gid://shopify/Collection/841564295",
"title": "IPods",
"handle": "ipods",
"updatedAt": "2008-02-02T00:00:00Z"
}
}
}
### Get a metafield attached to a collection
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CollectionMetafield($namespace: String!, $key: String!, $ownerId: ID!) { collection(id: $ownerId) { subtitle: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"subtitle\",\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n collection(id: $ownerId) {\n subtitle: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"subtitle\",\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n"
Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CollectionMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n collection(id: $ownerId) {\n subtitle: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"subtitle\",\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n"
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CollectionMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n collection(id: $ownerId) {\n subtitle: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"subtitle\",\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n"
Graphql query: "query CollectionMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n collection(id: $ownerId) {\n subtitle: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}"
#### Graphql Input
{
"namespace": "my_fields",
"key": "subtitle",
"ownerId": "gid://shopify/Collection/841564295"
}
#### Graphql Response
{
"data": {
"collection": {
"subtitle": {
"value": "Best of the best"
}
}
}
}
### Get metafields attached to a collection
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CollectionMetafields($ownerId: ID!) { collection(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionMetafields($ownerId: ID!) {\n collection(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n"
Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CollectionMetafields($ownerId: ID!) {\n collection(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n"
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CollectionMetafields($ownerId: ID!) {\n collection(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"ownerId\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n"
Graphql query: "query CollectionMetafields($ownerId: ID!) {\n collection(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}"
#### Graphql Input
{
"ownerId": "gid://shopify/Collection/841564295"
}
#### Graphql Response
{
"data": {
"collection": {
"metafields": {
"edges": [
{
"node": {
"namespace": "my_fields",
"key": "subtitle",
"value": "Best of the best"
}
}
]
}
}
}
}
### Get pinned metafield definitions associated with a collection
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CollectionMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { collection(id: $ownerId) { metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) { edges { node { name namespace key type { name } } } } } }\",\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Collection/841564295\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n collection(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Collection/841564295\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n});\n"
Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CollectionMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n collection(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Collection/841564295\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n}\n\nresponse = client.query(query: query, variables: variables)\n"
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CollectionMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n collection(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"pinnedStatus\": \"PINNED\",\n \"ownerId\": \"gid://shopify/Collection/841564295\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n"
Graphql query: "query CollectionMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n collection(id: $ownerId) {\n metafieldDefinitions(first: $first, pinnedStatus: $pinnedStatus, sortKey: $sortKey) {\n edges {\n node {\n name\n namespace\n key\n type {\n name\n }\n }\n }\n }\n }\n}"
#### Graphql Input
{
"pinnedStatus": "PINNED",
"ownerId": "gid://shopify/Collection/841564295",
"first": 10,
"sortKey": "PINNED_POSITION"
}
#### Graphql Response
{
"data": {
"collection": {
"metafieldDefinitions": {
"edges": [
{
"node": {
"name": "Target Audience",
"namespace": "my_fields",
"key": "target_audience",
"type": {
"name": "single_line_text_field"
}
}
},
{
"node": {
"name": "Subtitle",
"namespace": "my_fields",
"key": "subtitle",
"type": {
"name": "single_line_text_field"
}
}
}
]
}
}
}
}
### Retrieve product_ids
that are published to a collection_id
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CollectionShow($id: ID!) { collection(id: $id) { publishedOnCurrentPublication id title descriptionHtml updatedAt handle products(first: 10) { nodes { id } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n }\n}'\n"
Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n"
Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n"
Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n"
Graphql query: "query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n}"
#### Graphql Input
{
"id": "gid://shopify/Collection/841564295"
}
#### Graphql Response
{
"data": {
"collection": {
"publishedOnCurrentPublication": true,
"id": "gid://shopify/Collection/841564295",
"title": "IPods",
"descriptionHtml": "
The best selling ipod ever
", "updatedAt": "2008-02-02T00:00:00Z", "handle": "ipods", "products": { "nodes": [ { "id": "gid://shopify/Product/632910392" } ] } } } } ### Retrieve a list of products belonging to a collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetCollection($id: ID!) { collection(id: $id) { id title description handle image { url } products(first: 10) { nodes { id title } } updatedAt } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n}" #### Graphql Input { "id": "gid://shopify/Collection/841564295" } #### Graphql Response { "data": { "collection": { "id": "gid://shopify/Collection/841564295", "title": "IPods", "description": "The best selling ipod ever", "handle": "ipods", "image": { "url": "https://cdn.shopify.com/s/files/1/0005/4838/0009/collections/ipod_nano_8gb.jpg?v=1733171181" }, "products": { "nodes": [ { "id": "gid://shopify/Product/632910392", "title": "IPod Nano - 8GB" } ] }, "updatedAt": "2008-02-02T00:00:00Z" } } } ### Retrieve a specific collection listing that is published to your app Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CollectionShow($id: ID!) { collection(id: $id) { publishedOnCurrentPublication id title descriptionHtml updatedAt handle image { id height width url } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n image {\n id\n height\n width\n url\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Collection/841564295" } #### Graphql Response { "data": { "collection": { "publishedOnCurrentPublication": true, "id": "gid://shopify/Collection/841564295", "title": "IPods", "descriptionHtml": "The best selling ipod ever
", "updatedAt": "2008-02-02T00:00:00Z", "handle": "ipods", "image": { "id": "gid://shopify/CollectionImage/867761954", "height": 456, "width": 123, "url": "https://cdn.shopify.com/s/files/1/0005/4838/0009/collections/ipod_nano_8gb.jpg?v=1733171181" } } } } ### Retrieves a count of collects Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetCollectionProductCount($collectionId: ID!) { collection(id: $collectionId) { productsCount { count precision } } }\",\n \"variables\": {\n \"collectionId\": \"gid://shopify/Collection/841564295\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetCollectionProductCount($collectionId: ID!) {\n collection(id: $collectionId) {\n productsCount {\n count\n precision\n }\n }\n }`,\n \"variables\": {\n \"collectionId\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query GetCollectionProductCount($collectionId: ID!) {\n collection(id: $collectionId) {\n productsCount {\n count\n precision\n }\n }\n }\nQUERY\n\nvariables = {\n \"collectionId\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query GetCollectionProductCount($collectionId: ID!) {\n collection(id: $collectionId) {\n productsCount {\n count\n precision\n }\n }\n }`,\n {\n variables: {\n \"collectionId\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetCollectionProductCount($collectionId: ID!) {\n collection(id: $collectionId) {\n productsCount {\n count\n precision\n }\n }\n}" #### Graphql Input { "collectionId": "gid://shopify/Collection/841564295" } #### Graphql Response { "data": { "collection": { "productsCount": { "count": 1, "precision": "EXACT" } } } } ### Retrieves a single collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query CollectionShow($id: ID!) { collection(id: $id) { publishedOnCurrentPublication id title descriptionHtml updatedAt handle products(first: 10) { nodes { id } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CollectionShow($id: ID!) {\n collection(id: $id) {\n publishedOnCurrentPublication\n id\n title\n descriptionHtml\n updatedAt\n handle\n products(first: 10) {\n nodes {\n id\n }\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Collection/841564295" } #### Graphql Response { "data": { "collection": { "publishedOnCurrentPublication": true, "id": "gid://shopify/Collection/841564295", "title": "IPods", "descriptionHtml": "The best selling ipod ever
", "updatedAt": "2008-02-02T00:00:00Z", "handle": "ipods", "products": { "nodes": [ { "id": "gid://shopify/Product/632910392" } ] } } } } ### Retrieves a single custom collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetCollection($id: ID!) { collection(id: $id) { id title description handle image { url } products(first: 10) { nodes { id title } } updatedAt } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n}" #### Graphql Input { "id": "gid://shopify/Collection/841564295" } #### Graphql Response { "data": { "collection": { "id": "gid://shopify/Collection/841564295", "title": "IPods", "description": "The best selling ipod ever", "handle": "ipods", "image": { "url": "https://cdn.shopify.com/s/files/1/0005/4838/0009/collections/ipod_nano_8gb.jpg?v=1733171181" }, "products": { "nodes": [ { "id": "gid://shopify/Product/632910392", "title": "IPod Nano - 8GB" } ] }, "updatedAt": "2008-02-02T00:00:00Z" } } } ### Retrieves a single smart collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetCollection($id: ID!) { collection(id: $id) { id title description handle image { url } products(first: 10) { nodes { id title } } updatedAt } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Collection/841564295\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Collection/841564295\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetCollection($id: ID!) {\n collection(id: $id) {\n id\n title\n description\n handle\n image {\n url\n }\n products(first: 10) {\n nodes {\n id\n title\n }\n }\n updatedAt\n }\n}" #### Graphql Input { "id": "gid://shopify/Collection/841564295" } #### Graphql Response { "data": { "collection": { "id": "gid://shopify/Collection/841564295", "title": "IPods", "description": "The best selling ipod ever", "handle": "ipods", "image": { "url": "https://cdn.shopify.com/s/files/1/0005/4838/0009/collections/ipod_nano_8gb.jpg?v=1733171181" }, "products": { "nodes": [ { "id": "gid://shopify/Product/632910392", "title": "IPod Nano - 8GB" } ] }, "updatedAt": "2008-02-02T00:00:00Z" } } } ### Returns null when collection is not found Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { collection(id: \\\"gid://shopify/Collection/-1\\\") { id title } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n collection(id: \"gid://shopify/Collection/-1\") {\n id\n title\n }\n }`,\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n query {\n collection(id: \"gid://shopify/Collection/-1\") {\n id\n title\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n collection(id: \"gid://shopify/Collection/-1\") {\n id\n title\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n collection(id: \"gid://shopify/Collection/-1\") {\n id\n title\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "collection": null } }