# Collection - admin-graphql - OBJECT Version: unstable ## Description 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. ### Access Scopes `read_products` access scope. ## Fields * [availablePublicationsCount](/docs/api/admin-graphql/unstable/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/unstable/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/unstable/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/unstable/objects/ResourceFeedback): ResourceFeedback - Information about the collection that's provided through resource feedback. * [handle](/docs/api/admin-graphql/unstable/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/unstable/scalars/Boolean): Boolean! - Whether the collection includes the specified product. * [id](/docs/api/admin-graphql/unstable/scalars/ID): ID! - A globally-unique ID. * [image](/docs/api/admin-graphql/unstable/objects/Image): Image - The image associated with the collection. * [legacyResourceId](/docs/api/admin-graphql/unstable/scalars/UnsignedInt64): UnsignedInt64! - The ID of the corresponding resource in the REST Admin API. * [metafield](/docs/api/admin-graphql/unstable/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. * [metafieldsByIdentifiers](/docs/api/admin-graphql/unstable/objects/Metafield): Metafield! - The metafields associated with the resource matching the supplied list of namespaces and keys. * [privateMetafield](/docs/api/admin-graphql/unstable/objects/PrivateMetafield): PrivateMetafield - Returns a private metafield by namespace and key that belongs to the resource. * [publicationCount](/docs/api/admin-graphql/unstable/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/unstable/scalars/Boolean): Boolean! - Whether the resource is published to a specific channel. * [publishedOnCurrentChannel](/docs/api/admin-graphql/unstable/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/unstable/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/unstable/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/unstable/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/unstable/objects/CollectionRuleSet): CollectionRuleSet - For a smart (automated) collection, specifies the rules that determine whether a product is included. * [seo](/docs/api/admin-graphql/unstable/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/unstable/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/unstable/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/unstable/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/unstable/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/unstable/objects/Translation): Translation! - The published translations associated with the resource. * [updatedAt](/docs/api/admin-graphql/unstable/scalars/DateTime): DateTime! - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) when the collection was last modified. ## Connections * [events](/docs/api/admin-graphql/unstable/connections/EventConnection): EventConnection! * [metafieldDefinitions](/docs/api/admin-graphql/unstable/connections/MetafieldDefinitionConnection): MetafieldDefinitionConnection! * [metafields](/docs/api/admin-graphql/unstable/connections/MetafieldConnection): MetafieldConnection! * [privateMetafields](/docs/api/admin-graphql/unstable/connections/PrivateMetafieldConnection): PrivateMetafieldConnection! * [products](/docs/api/admin-graphql/unstable/connections/ProductConnection): ProductConnection! * [publications](/docs/api/admin-graphql/unstable/connections/CollectionPublicationConnection): CollectionPublicationConnection! * [resourcePublications](/docs/api/admin-graphql/unstable/connections/ResourcePublicationConnection): ResourcePublicationConnection! * [resourcePublicationsV2](/docs/api/admin-graphql/unstable/connections/ResourcePublicationV2Connection): ResourcePublicationV2Connection! * [unpublishedChannels](/docs/api/admin-graphql/unstable/connections/ChannelConnection): ChannelConnection! * [unpublishedPublications](/docs/api/admin-graphql/unstable/connections/PublicationConnection): PublicationConnection! ## Related queries * [collection](/docs/api/admin-graphql/unstable/queries/collection) Returns a Collection resource by ID. * [collectionByHandle](/docs/api/admin-graphql/unstable/queries/collectionByHandle) Return a collection by its handle. * [collections](/docs/api/admin-graphql/unstable/queries/collections) Returns a list of collections. ## Related mutations * [collectionAddProducts](/docs/api/admin-graphql/unstable/mutations/collectionAddProducts) Adds products to a collection. * [collectionCreate](/docs/api/admin-graphql/unstable/mutations/collectionCreate) Creates a collection. * [collectionPublish](/docs/api/admin-graphql/unstable/mutations/collectionPublish) Publishes a collection to a channel. * [collectionUnpublish](/docs/api/admin-graphql/unstable/mutations/collectionUnpublish) Unpublishes a collection. * [collectionUpdate](/docs/api/admin-graphql/unstable/mutations/collectionUpdate) Updates a collection. ## Related Unions * [MetafieldReference](/docs/api/admin-graphql/unstable/unions/MetafieldReference) The resource referenced by the metafield value. * [MetafieldReferencer](/docs/api/admin-graphql/unstable/unions/MetafieldReferencer) Types of resources that may use metafields to reference other resources. ## Examples ### Get a metafield attached to a collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/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/unstable/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/unstable/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 a list of products belonging to a collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/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=1731426897" }, "products": { "nodes": [ { "id": "gid://shopify/Product/632910392", "title": "IPod Nano - 8GB" } ] }, "updatedAt": "2008-02-02T00:00:00Z" } } } ### Retrieves a single collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/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" } } } ### Retrieves a single custom collection Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/unstable/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=1731426897" }, "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/unstable/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=1731426897" }, "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/unstable/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 } }