# Product - admin-graphql - OBJECT Version: 2024-10 ## Description The `Product` object lets you manage products in a merchant’s store. Products are the goods and services that merchants offer to customers. They can include various details such as title, description, price, images, and options such as size or color. You can use [product variants](https://shopify.dev/docs/api/admin-graphql/latest/objects/productvariant) to create or update different versions of the same product. You can also add or update product [media](https://shopify.dev/docs/api/admin-graphql/latest/interfaces/media). Products can be organized by grouping them into a [collection](https://shopify.dev/docs/api/admin-graphql/latest/objects/collection). Learn more about working with [Shopify's product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components), including limitations and considerations. ### Access Scopes `read_products` access scope. ## Fields * [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). * [bodyHtml](/docs/api/admin-graphql/2024-10/scalars/String): String - The description of the product, with HTML tags. For example, the description might include bold `` and italic `` text. * [category](/docs/api/admin-graphql/2024-10/objects/TaxonomyCategory): TaxonomyCategory - The category of a product from [Shopify's Standard Product Taxonomy](https://shopify.github.io/product-taxonomy/releases/unstable/?categoryId=sg-4-17-2-17). * [combinedListing](/docs/api/admin-graphql/2024-10/objects/CombinedListing): CombinedListing - A special product type that combines separate products from a store into a single product listing. [Combined listings](https://shopify.dev/apps/build/product-merchandising/combined-listings) are connected by a shared option, such as color, model, or dimension. * [combinedListingRole](/docs/api/admin-graphql/2024-10/enums/CombinedListingsRole): CombinedListingsRole - The [role of the product](https://shopify.dev/docs/apps/build/product-merchandising/combined-listings/build-for-combined-listings) in a combined listing. If `null`, then the product isn't part of any combined listing. * [compareAtPriceRange](/docs/api/admin-graphql/2024-10/objects/ProductCompareAtPriceRange): ProductCompareAtPriceRange - The [compare-at price range](https://help.shopify.com/manual/products/details/product-pricing/sale-pricing) of the product in the shop's default currency. * [contextualPricing](/docs/api/admin-graphql/2024-10/objects/ProductContextualPricing): ProductContextualPricing! - The pricing that applies to a customer in a specific context. For example, a price might vary depending on the customer's location. * [createdAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime! - The date and time when the product was created. * [customProductType](/docs/api/admin-graphql/2024-10/scalars/String): String - The custom product type specified by the merchant. * [defaultCursor](/docs/api/admin-graphql/2024-10/scalars/String): String! - A default [cursor](https://shopify.dev/api/usage/pagination-graphql) that returns the single next record, sorted ascending by ID. * [description](/docs/api/admin-graphql/2024-10/scalars/String): String! - A single-line description of the product, with [HTML tags](https://developer.mozilla.org/en-US/docs/Web/HTML) removed. * [descriptionHtml](/docs/api/admin-graphql/2024-10/scalars/HTML): HTML! - The description of the product, with HTML tags. For example, the description might include bold `` and italic `` text. * [descriptionPlainSummary](/docs/api/admin-graphql/2024-10/scalars/String): String! - Stripped description of the product, single line with HTML tags removed. Truncated to 60 characters. * [featuredImage](/docs/api/admin-graphql/2024-10/objects/Image): Image - The featured image for the product. * [featuredMedia](/docs/api/admin-graphql/2024-10/interfaces/Media): Media - The featured [media](https://shopify.dev/docs/apps/build/online-store/product-media) associated with the product. * [feedback](/docs/api/admin-graphql/2024-10/objects/ResourceFeedback): ResourceFeedback - The information that lets merchants know what steps they need to take to make sure that the app is set up correctly. For example, if a merchant hasn't set up a product correctly in the app, then the feedback might include a message that says "You need to add a price to this product". * [giftCardTemplateSuffix](/docs/api/admin-graphql/2024-10/scalars/String): String - The [theme template](https://shopify.dev/docs/storefronts/themes/architecture/templates) that's used when customers view the gift card in a store. * [handle](/docs/api/admin-graphql/2024-10/scalars/String): String! - A unique, human-readable string of the product's title. A handle can contain letters, hyphens (`-`), and numbers, but no spaces. The handle is used in the online store URL for the product. * [hasOnlyDefaultVariant](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product has only a single variant with the default option and value. * [hasOutOfStockVariants](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product has variants that are out of stock. * [hasVariantsThatRequiresComponents](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether at least one of the product variants requires [bundle components](https://shopify.dev/docs/apps/build/product-merchandising/bundles/add-product-fixed-bundle). Learn more about [store eligibility for bundles](https://shopify.dev/docs/apps/build/product-merchandising/bundles#store-eligibility). * [id](/docs/api/admin-graphql/2024-10/scalars/ID): ID! - A globally-unique ID. * [inCollection](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product is in a specified [collection](https://shopify.dev/docs/api/admin-graphql/latest/objects/collection). * [isGiftCard](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product is a gift card. * [legacyResourceId](/docs/api/admin-graphql/2024-10/scalars/UnsignedInt64): UnsignedInt64! - The ID of the corresponding resource in the REST Admin API. * [mediaCount](/docs/api/admin-graphql/2024-10/objects/Count): Count - The total count of [media](https://shopify.dev/docs/apps/build/online-store/product-media) that's associated with a product. * [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. * [onlineStorePreviewUrl](/docs/api/admin-graphql/2024-10/scalars/URL): URL - The [preview URL](https://help.shopify.com/manual/online-store/setting-up#preview-your-store) for the online store. * [onlineStoreUrl](/docs/api/admin-graphql/2024-10/scalars/URL): URL - The product's URL on the online store. If `null`, then the product isn't published to the online store sales channel. * [options](/docs/api/admin-graphql/2024-10/objects/ProductOption): ProductOption! - A list of product options. The limit is defined by the [shop's resource limits for product options](https://shopify.dev/docs/api/admin-graphql/latest/objects/Shop#field-resourcelimits) (`Shop.resourceLimits.maxProductOptions`). * [priceRange](/docs/api/admin-graphql/2024-10/objects/ProductPriceRange): ProductPriceRange! - The price range of the product. * [priceRangeV2](/docs/api/admin-graphql/2024-10/objects/ProductPriceRangeV2): ProductPriceRangeV2! - The minimum and maximum prices of a product, expressed in decimal numbers. For example, if the product is priced between $10.00 and $50.00, then the price range is $10.00 - $50.00. * [privateMetafield](/docs/api/admin-graphql/2024-10/objects/PrivateMetafield): PrivateMetafield - Returns a private metafield by namespace and key that belongs to the resource. * [productCategory](/docs/api/admin-graphql/2024-10/objects/ProductCategory): ProductCategory - The product category specified by the merchant. * [productType](/docs/api/admin-graphql/2024-10/scalars/String): String! - The [product type](https://help.shopify.com/manual/products/details/product-type) that merchants define. * [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). * [publishedAt](/docs/api/admin-graphql/2024-10/scalars/DateTime): DateTime - The date and time when the product was published to the online store. * [publishedInContext](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product is published for a customer only in a specified context. For example, a product might be published for a customer only in a specific location. * [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). * [requiresSellingPlan](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether the product can only be purchased with a [selling plan](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans). Products that are sold on subscription (`requiresSellingPlan: true`) can be updated only for online stores. If you update a product to be subscription-only (`requiresSellingPlan:false`), then the product is unpublished from all channels, except the online store. * [resourcePublicationOnCurrentPublication](/docs/api/admin-graphql/2024-10/objects/ResourcePublicationV2): ResourcePublicationV2 - The resource that's either published or staged to be published to the [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). * [restrictedForResource](/docs/api/admin-graphql/2024-10/objects/RestrictedForResource): RestrictedForResource - Whether the merchant can make changes to the product when they [edit the order](https://shopify.dev/docs/apps/build/orders-fulfillment/order-management-apps/edit-orders) associated with the product. For example, a merchant might be restricted from changing product details when they edit an order. * [sellingPlanGroupCount](/docs/api/admin-graphql/2024-10/scalars/Int): Int! - A count of [selling plan groups](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans/build-a-selling-plan) that are associated with the product. * [sellingPlanGroupsCount](/docs/api/admin-graphql/2024-10/objects/Count): Count - A count of [selling plan groups](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans/build-a-selling-plan) that are associated with the product. * [seo](/docs/api/admin-graphql/2024-10/objects/SEO): SEO! - The [SEO title and description](https://help.shopify.com/manual/promoting-marketing/seo/adding-keywords) that are associated with a product. * [standardizedProductType](/docs/api/admin-graphql/2024-10/objects/StandardizedProductType): StandardizedProductType - The standardized product type in the Shopify product taxonomy. * [status](/docs/api/admin-graphql/2024-10/enums/ProductStatus): ProductStatus! - The [product status](https://help.shopify.com/manual/products/details/product-details-page#product-status), which controls visibility across all sales channels. * [storefrontId](/docs/api/admin-graphql/2024-10/scalars/StorefrontID): StorefrontID! - The Storefront GraphQL API ID of the `Product`. 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. * [tags](/docs/api/admin-graphql/2024-10/scalars/String): String! - A comma-separated list of searchable keywords that are associated with the product. For example, a merchant might apply the `sports` and `summer` tags to products that are associated with sportwear for summer. Updating `tags` overwrites any existing tags that were previously added to the product. To add new tags without overwriting existing tags, use the [`tagsAdd`](https://shopify.dev/api/admin-graphql/latest/mutations/tagsadd) mutation. * [templateSuffix](/docs/api/admin-graphql/2024-10/scalars/String): String - The [theme template](https://shopify.dev/docs/storefronts/themes/architecture/templates) that's used when customers view the product in a store. * [title](/docs/api/admin-graphql/2024-10/scalars/String): String! - The name for the product that displays to customers. The title is used to construct the product's handle. For example, if a product is titled "Black Sunglasses", then the handle is `black-sunglasses`. * [totalInventory](/docs/api/admin-graphql/2024-10/scalars/Int): Int! - The quantity of inventory that's in stock. * [totalVariants](/docs/api/admin-graphql/2024-10/scalars/Int): Int! - The number of [variants](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) that are associated with the product. * [tracksInventory](/docs/api/admin-graphql/2024-10/scalars/Boolean): Boolean! - Whether [inventory tracking](https://help.shopify.com/manual/products/inventory/getting-started-with-inventory/set-up-inventory-tracking) has been enabled for the product. * [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 when the product was last modified. A product's `updatedAt` value can change for different reasons. For example, if an order is placed for a product that has inventory tracking set up, then the inventory adjustment is counted as an update. * [variantsCount](/docs/api/admin-graphql/2024-10/objects/Count): Count - The number of [variants](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) that are associated with the product. * [vendor](/docs/api/admin-graphql/2024-10/scalars/String): String! - The name of the product's vendor. ## Connections * [bundleComponents](/docs/api/admin-graphql/2024-10/connections/ProductBundleComponentConnection): ProductBundleComponentConnection! * [collections](/docs/api/admin-graphql/2024-10/connections/CollectionConnection): CollectionConnection! * [events](/docs/api/admin-graphql/2024-10/connections/EventConnection): EventConnection! * [images](/docs/api/admin-graphql/2024-10/connections/ImageConnection): ImageConnection! * [media](/docs/api/admin-graphql/2024-10/connections/MediaConnection): MediaConnection! * [metafieldDefinitions](/docs/api/admin-graphql/2024-10/connections/MetafieldDefinitionConnection): MetafieldDefinitionConnection! * [metafields](/docs/api/admin-graphql/2024-10/connections/MetafieldConnection): MetafieldConnection! * [privateMetafields](/docs/api/admin-graphql/2024-10/connections/PrivateMetafieldConnection): PrivateMetafieldConnection! * [productPublications](/docs/api/admin-graphql/2024-10/connections/ProductPublicationConnection): ProductPublicationConnection! * [publications](/docs/api/admin-graphql/2024-10/connections/ProductPublicationConnection): ProductPublicationConnection! * [resourcePublications](/docs/api/admin-graphql/2024-10/connections/ResourcePublicationConnection): ResourcePublicationConnection! * [resourcePublicationsV2](/docs/api/admin-graphql/2024-10/connections/ResourcePublicationV2Connection): ResourcePublicationV2Connection! * [sellingPlanGroups](/docs/api/admin-graphql/2024-10/connections/SellingPlanGroupConnection): SellingPlanGroupConnection! * [unpublishedChannels](/docs/api/admin-graphql/2024-10/connections/ChannelConnection): ChannelConnection! * [unpublishedPublications](/docs/api/admin-graphql/2024-10/connections/PublicationConnection): PublicationConnection! * [variants](/docs/api/admin-graphql/2024-10/connections/ProductVariantConnection): ProductVariantConnection! ## Related queries * [product](/docs/api/admin-graphql/2024-10/queries/product) Returns a Product resource by ID. * [productByHandle](/docs/api/admin-graphql/2024-10/queries/productByHandle) Return a product by its handle. * [products](/docs/api/admin-graphql/2024-10/queries/products) Returns a list of products. ## Related mutations * [combinedListingUpdate](/docs/api/admin-graphql/2024-10/mutations/combinedListingUpdate) Add, remove and update `CombinedListing`s of a given Product. `CombinedListing`s are comprised of multiple products to create a single listing. There are two kinds of products used in a `CombinedListing`: 1. Parent products 2. Child products The parent product is created with a `productCreate` with a `CombinedListingRole` of `PARENT`. Once created, you can associate child products with the parent product using this mutation. Parent products represent the idea of a product (e.g. Shoe). Child products represent a particular option value (or combination of option values) of a parent product. For instance, with your Shoe parent product, you may have several child products representing specific colors of the shoe (e.g. Shoe - Blue). You could also have child products representing more than a single option (e.g. Shoe - Blue/Canvas, Shoe - Blue/Leather, etc...). The combined listing is the association of parent product to one or more child products. Learn more about [Combined Listings](https://shopify.dev/apps/selling-strategies/combined-listings). * [priceListFixedPricesByProductUpdate](/docs/api/admin-graphql/2024-10/mutations/priceListFixedPricesByProductUpdate) Updates the fixed prices for all variants for a product on a price list. You can use the `priceListFixedPricesByProductUpdate` mutation to set or remove a fixed price for all variants of a product associated with the price list. * [productChangeStatus](/docs/api/admin-graphql/2024-10/mutations/productChangeStatus) Changes the status of a product. This allows you to set the availability of the product across all channels. * [productCreateMedia](/docs/api/admin-graphql/2024-10/mutations/productCreateMedia) Creates media for a product. * [productCreate](/docs/api/admin-graphql/2024-10/mutations/productCreate) Creates a product. Learn more about the [product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model) and [adding product data](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/add-data). * [productDeleteMedia](/docs/api/admin-graphql/2024-10/mutations/productDeleteMedia) Deletes media for a product. * [productDuplicate](/docs/api/admin-graphql/2024-10/mutations/productDuplicate) Duplicates a product. If you need to duplicate a large product, such as one that has many [variants](https://shopify.dev/api/admin-graphql/latest/input-objects/ProductVariantInput) that are active at several [locations](https://shopify.dev/api/admin-graphql/latest/input-objects/InventoryLevelInput), you might encounter timeout errors. To avoid these timeout errors, you can instead duplicate the product asynchronously. In API version 2024-10 and higher, include `synchronous: false` argument in this mutation to perform the duplication asynchronously. In API version 2024-07 and lower, use the asynchronous [`ProductDuplicateAsyncV2`](https://shopify.dev/api/admin-graphql/2024-07/mutations/productDuplicateAsyncV2). * [productJoinSellingPlanGroups](/docs/api/admin-graphql/2024-10/mutations/productJoinSellingPlanGroups) Adds multiple selling plan groups to a product. * [productLeaveSellingPlanGroups](/docs/api/admin-graphql/2024-10/mutations/productLeaveSellingPlanGroups) Removes multiple groups from a product. * [productOptionUpdate](/docs/api/admin-graphql/2024-10/mutations/productOptionUpdate) Updates a product option. * [productOptionsCreate](/docs/api/admin-graphql/2024-10/mutations/productOptionsCreate) Creates options on a product. * [productOptionsDelete](/docs/api/admin-graphql/2024-10/mutations/productOptionsDelete) Deletes the specified options. * [productOptionsReorder](/docs/api/admin-graphql/2024-10/mutations/productOptionsReorder) Reorders options and option values on a product, causing product variants to alter their position. Options order take precedence over option values order. Depending on the existing product variants, some input orders might not be achieved. Example: Existing product variants: ["Red / Small", "Green / Medium", "Blue / Small"]. New order: [ { name: "Size", values: [{ name: "Small" }, { name: "Medium" }], name: "Color", values: [{ name: "Green" }, { name: "Red" }, { name: "Blue" }] } ]. Description: Variants with "Green" value are expected to appear before variants with "Red" and "Blue" values. However, "Size" option appears before "Color". Therefore, output will be: ["Small / "Red", "Small / Blue", "Medium / Green"]. * [productPublish](/docs/api/admin-graphql/2024-10/mutations/productPublish) Publishes a product. Products that are sold exclusively on subscription (`requiresSellingPlan: true`) can only be published on online stores. * [productSet](/docs/api/admin-graphql/2024-10/mutations/productSet) Creates or updates a product in a single request. Use this mutation when syncing information from an external data source into Shopify. When using this mutation to update a product, specify that product's `id` in the input. Any list field (e.g. [collections](https://shopify.dev/api/admin-graphql/current/input-objects/ProductSetInput#field-productsetinput-collections), [metafields](https://shopify.dev/api/admin-graphql/current/input-objects/ProductSetInput#field-productsetinput-metafields), [variants](https://shopify.dev/api/admin-graphql/current/input-objects/ProductSetInput#field-productsetinput-variants)) will be updated so that all included entries are either created or updated, and all existing entries not included will be deleted. All other fields will be updated to the value passed. Omitted fields will not be updated. When run in synchronous mode, the `productSet` mutation has an input limit of 100 variants. If you anticipate any of your use cases requiring support for more than 100 variants, please use the mutation in asynchronous mode (default). When run in synchronous mode, you will get the product back in the response. In asynchronous mode, you will instead get a [ProductSetOperation](https://shopify.dev/api/admin-graphql/current/objects/ProductSetOperation) object back. You can then use the [productOperation](https://shopify.dev/api/admin-graphql/current/queries/productOperation) query to retrieve the updated product data. This query uses the `ProductSetOperation` object to check the status of the operation and to retrieve the details of the updated product and its variants. If you need to update a subset of variants, use one of the bulk variant mutations: - [productVariantsBulkCreate](https://shopify.dev/api/admin-graphql/current/mutations/productVariantsBulkCreate) - [productVariantsBulkUpdate](https://shopify.dev/api/admin-graphql/current/mutations/productVariantsBulkUpdate) - [productVariantsBulkDelete](https://shopify.dev/api/admin-graphql/current/mutations/productVariantsBulkDelete) If you need to update options, use one of the product option mutations: - [productOptionsCreate](https://shopify.dev/api/admin-graphql/current/mutations/productOptionsCreate) - [productOptionUpdate](https://shopify.dev/api/admin-graphql/current/mutations/productOptionUpdate) - [productOptionsDelete](https://shopify.dev/api/admin-graphql/current/mutations/productOptionsDelete) - [productOptionsReorder](https://shopify.dev/api/admin-graphql/current/mutations/productOptionsReorder) See our guide to [sync product data from an external source](https://shopify.dev/api/admin/migrate/new-product-model/sync-data) for more. * [productUnpublish](/docs/api/admin-graphql/2024-10/mutations/productUnpublish) Unpublishes a product. * [productUpdateMedia](/docs/api/admin-graphql/2024-10/mutations/productUpdateMedia) Updates media for a product. * [productUpdate](/docs/api/admin-graphql/2024-10/mutations/productUpdate) Updates a product. For versions `2024-01` and older: If you update a product and only include some variants in the update, then any variants not included will be deleted. To safely manage variants without the risk of deleting excluded variants, use [productVariantsBulkUpdate](https://shopify.dev/api/admin-graphql/latest/mutations/productvariantsbulkupdate). If you want to update a single variant, then use [productVariantUpdate](https://shopify.dev/api/admin-graphql/latest/mutations/productvariantupdate). * [productVariantAppendMedia](/docs/api/admin-graphql/2024-10/mutations/productVariantAppendMedia) Appends media from a product to variants of the product. * [productVariantDetachMedia](/docs/api/admin-graphql/2024-10/mutations/productVariantDetachMedia) Detaches media from product variants. * [productVariantsBulkCreate](/docs/api/admin-graphql/2024-10/mutations/productVariantsBulkCreate) Creates multiple variants in a single product. This mutation can be called directly or via the bulkOperation. * [productVariantsBulkDelete](/docs/api/admin-graphql/2024-10/mutations/productVariantsBulkDelete) Deletes multiple variants in a single product. This mutation can be called directly or via the bulkOperation. * [productVariantsBulkReorder](/docs/api/admin-graphql/2024-10/mutations/productVariantsBulkReorder) Reorders multiple variants in a single product. This mutation can be called directly or via the bulkOperation. * [productVariantsBulkUpdate](/docs/api/admin-graphql/2024-10/mutations/productVariantsBulkUpdate) Updates multiple variants in a single product. This mutation can be called directly or via the bulkOperation. ## Related Unions * [CommentEventEmbed](/docs/api/admin-graphql/2024-10/unions/CommentEventEmbed) The main embed of a comment event. * [MetafieldReference](/docs/api/admin-graphql/2024-10/unions/MetafieldReference) The resource referenced by the metafield value. * [MetafieldReferencer](/docs/api/admin-graphql/2024-10/unions/MetafieldReferencer) Types of resources that may use metafields to reference other resources. ## Examples ### Get a metafield attached to a product 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 ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) { product(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n product(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/Product/108828309\"\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 ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n product(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY\n\nvariables = {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/Product/108828309\"\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 ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n product(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }`,\n {\n variables: {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n product(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}" #### Graphql Input { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/Product/108828309" } #### Graphql Response { "data": { "product": { "linerMaterial": { "value": "synthetic leather" } } } } ### Get a product using the QueryRoot.node field and a GraphQL fragment 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 { node(id: \\\"gid://shopify/Product/108828309\\\") { id ... on Product { title } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n node(id: \"gid://shopify/Product/108828309\") {\n id\n ... on Product {\n title\n }\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 node(id: \"gid://shopify/Product/108828309\") {\n id\n ... on Product {\n title\n }\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 node(id: \"gid://shopify/Product/108828309\") {\n id\n ... on Product {\n title\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n node(id: \"gid://shopify/Product/108828309\") {\n id\n ... on Product {\n title\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "node": { "id": "gid://shopify/Product/108828309", "title": "Draft" } } } ### Get all a product's fields and connections 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 { product(id: \\\"gid://shopify/Product/108828309\\\") { collections(first: 5) { edges { node { handle } } } createdAt defaultCursor description descriptionHtml featuredImage { id } feedback { details { messages { message } } } giftCardTemplateSuffix handle hasOnlyDefaultVariant hasOutOfStockVariants id images(first: 5) { edges { node { id } } } inCollection(id: \\\"gid://shopify/Collection/1007901140\\\") isGiftCard legacyResourceId metafield(key: \\\"app_key\\\", namespace: \\\"affiliates\\\") { description } metafields(first: 5) { edges { node { description } } } onlineStorePreviewUrl onlineStoreUrl options { name } priceRange { maxVariantPrice { amount } minVariantPrice { amount } } productType resourcePublicationsCount { count } availablePublicationsCount { count } publishedAt resourcePublications(first: 5) { edges { node { isPublished } } } resourcePublicationOnCurrentPublication { publication { name id } publishDate isPublished } seo { title } storefrontId tags templateSuffix title totalInventory tracksInventory unpublishedPublications(first: 5) { edges { node { name } } } updatedAt variants(first: 5) { edges { node { displayName } } } variantsCount { count } vendor } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/108828309\") {\n collections(first: 5) {\n edges {\n node {\n handle\n }\n }\n }\n createdAt\n defaultCursor\n description\n descriptionHtml\n featuredImage {\n id\n }\n feedback {\n details {\n messages {\n message\n }\n }\n }\n giftCardTemplateSuffix\n handle\n hasOnlyDefaultVariant\n hasOutOfStockVariants\n id\n images(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n inCollection(id: \"gid://shopify/Collection/1007901140\")\n isGiftCard\n legacyResourceId\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n description\n }\n }\n }\n onlineStorePreviewUrl\n onlineStoreUrl\n options {\n name\n }\n priceRange {\n maxVariantPrice {\n amount\n }\n minVariantPrice {\n amount\n }\n }\n productType\n resourcePublicationsCount {\n count\n }\n availablePublicationsCount {\n count\n }\n publishedAt\n resourcePublications(first: 5) {\n edges {\n node {\n isPublished\n }\n }\n }\n resourcePublicationOnCurrentPublication {\n publication {\n name\n id\n }\n publishDate\n isPublished\n }\n seo {\n title\n }\n storefrontId\n tags\n templateSuffix\n title\n totalInventory\n tracksInventory\n unpublishedPublications(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n updatedAt\n variants(first: 5) {\n edges {\n node {\n displayName\n }\n }\n }\n variantsCount {\n count\n }\n vendor\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 product(id: \"gid://shopify/Product/108828309\") {\n collections(first: 5) {\n edges {\n node {\n handle\n }\n }\n }\n createdAt\n defaultCursor\n description\n descriptionHtml\n featuredImage {\n id\n }\n feedback {\n details {\n messages {\n message\n }\n }\n }\n giftCardTemplateSuffix\n handle\n hasOnlyDefaultVariant\n hasOutOfStockVariants\n id\n images(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n inCollection(id: \"gid://shopify/Collection/1007901140\")\n isGiftCard\n legacyResourceId\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n description\n }\n }\n }\n onlineStorePreviewUrl\n onlineStoreUrl\n options {\n name\n }\n priceRange {\n maxVariantPrice {\n amount\n }\n minVariantPrice {\n amount\n }\n }\n productType\n resourcePublicationsCount {\n count\n }\n availablePublicationsCount {\n count\n }\n publishedAt\n resourcePublications(first: 5) {\n edges {\n node {\n isPublished\n }\n }\n }\n resourcePublicationOnCurrentPublication {\n publication {\n name\n id\n }\n publishDate\n isPublished\n }\n seo {\n title\n }\n storefrontId\n tags\n templateSuffix\n title\n totalInventory\n tracksInventory\n unpublishedPublications(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n updatedAt\n variants(first: 5) {\n edges {\n node {\n displayName\n }\n }\n }\n variantsCount {\n count\n }\n vendor\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 product(id: \"gid://shopify/Product/108828309\") {\n collections(first: 5) {\n edges {\n node {\n handle\n }\n }\n }\n createdAt\n defaultCursor\n description\n descriptionHtml\n featuredImage {\n id\n }\n feedback {\n details {\n messages {\n message\n }\n }\n }\n giftCardTemplateSuffix\n handle\n hasOnlyDefaultVariant\n hasOutOfStockVariants\n id\n images(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n inCollection(id: \"gid://shopify/Collection/1007901140\")\n isGiftCard\n legacyResourceId\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n description\n }\n }\n }\n onlineStorePreviewUrl\n onlineStoreUrl\n options {\n name\n }\n priceRange {\n maxVariantPrice {\n amount\n }\n minVariantPrice {\n amount\n }\n }\n productType\n resourcePublicationsCount {\n count\n }\n availablePublicationsCount {\n count\n }\n publishedAt\n resourcePublications(first: 5) {\n edges {\n node {\n isPublished\n }\n }\n }\n resourcePublicationOnCurrentPublication {\n publication {\n name\n id\n }\n publishDate\n isPublished\n }\n seo {\n title\n }\n storefrontId\n tags\n templateSuffix\n title\n totalInventory\n tracksInventory\n unpublishedPublications(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n updatedAt\n variants(first: 5) {\n edges {\n node {\n displayName\n }\n }\n }\n variantsCount {\n count\n }\n vendor\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/108828309\") {\n collections(first: 5) {\n edges {\n node {\n handle\n }\n }\n }\n createdAt\n defaultCursor\n description\n descriptionHtml\n featuredImage {\n id\n }\n feedback {\n details {\n messages {\n message\n }\n }\n }\n giftCardTemplateSuffix\n handle\n hasOnlyDefaultVariant\n hasOutOfStockVariants\n id\n images(first: 5) {\n edges {\n node {\n id\n }\n }\n }\n inCollection(id: \"gid://shopify/Collection/1007901140\")\n isGiftCard\n legacyResourceId\n metafield(key: \"app_key\", namespace: \"affiliates\") {\n description\n }\n metafields(first: 5) {\n edges {\n node {\n description\n }\n }\n }\n onlineStorePreviewUrl\n onlineStoreUrl\n options {\n name\n }\n priceRange {\n maxVariantPrice {\n amount\n }\n minVariantPrice {\n amount\n }\n }\n productType\n resourcePublicationsCount {\n count\n }\n availablePublicationsCount {\n count\n }\n publishedAt\n resourcePublications(first: 5) {\n edges {\n node {\n isPublished\n }\n }\n }\n resourcePublicationOnCurrentPublication {\n publication {\n name\n id\n }\n publishDate\n isPublished\n }\n seo {\n title\n }\n storefrontId\n tags\n templateSuffix\n title\n totalInventory\n tracksInventory\n unpublishedPublications(first: 5) {\n edges {\n node {\n name\n }\n }\n }\n updatedAt\n variants(first: 5) {\n edges {\n node {\n displayName\n }\n }\n }\n variantsCount {\n count\n }\n vendor\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "collections": { "edges": [ { "node": { "handle": "reorder_custom" } }, { "node": { "handle": "everything" } }, { "node": { "handle": "snowboards" } }, { "node": { "handle": "everything-custom" } }, { "node": { "handle": "featured_asc" } } ] }, "createdAt": "2005-01-02T00:00:00Z", "defaultCursor": "eyJsaW1pdCI6MSwib3JkZXIiOiJpZCBhc2MiLCJsYXN0X2lkIjoxMDg4MjgzMDksImxhc3RfdmFsdWUiOjEwODgyODMwOSwiZGlyZWN0aW9uIjoibmV4dCJ9", "description": "good board", "descriptionHtml": "

good board

", "featuredImage": { "id": "gid://shopify/ProductImage/183532652" }, "feedback": null, "giftCardTemplateSuffix": null, "handle": "draft", "hasOnlyDefaultVariant": false, "hasOutOfStockVariants": false, "id": "gid://shopify/Product/108828309", "images": { "edges": [ { "node": { "id": "gid://shopify/ProductImage/183532652" } }, { "node": { "id": "gid://shopify/ProductImage/731367280" } } ] }, "inCollection": true, "isGiftCard": false, "legacyResourceId": "108828309", "metafield": null, "metafields": { "edges": [ { "node": { "description": "German product title" } }, { "node": { "description": null } }, { "node": { "description": null } }, { "node": { "description": null } }, { "node": { "description": null } } ] }, "onlineStorePreviewUrl": "https://www.snowdevil.ca/products/draft", "onlineStoreUrl": "https://www.snowdevil.ca/products/draft", "options": [ { "name": "Title" } ], "priceRange": { "maxVariantPrice": { "amount": "1000.0" }, "minVariantPrice": { "amount": "1000.0" } }, "productType": "Snowboards", "resourcePublicationsCount": { "count": 4 }, "availablePublicationsCount": { "count": 4 }, "publishedAt": "2005-01-02T00:00:00Z", "resourcePublications": { "edges": [ { "node": { "isPublished": true } }, { "node": { "isPublished": true } }, { "node": { "isPublished": true } } ] }, "resourcePublicationOnCurrentPublication": { "publication": { "name": "Generic Channel", "id": "gid://shopify/Publication/762454635" }, "publishDate": "2005-01-02T00:00:00Z", "isPublished": true }, "seo": { "title": null }, "storefrontId": "gid://shopify/Product/108828309", "tags": [ "Deepsnow", "Dub Quote\"s", "quote's", "Wooden Core" ], "templateSuffix": null, "title": "Draft", "totalInventory": 1, "tracksInventory": true, "unpublishedPublications": { "edges": [ { "node": { "name": "" } }, { "node": { "name": "" } }, { "node": { "name": "" } }, { "node": { "name": "" } }, { "node": { "name": "Private app with all permissions" } } ] }, "updatedAt": "2005-01-02T00:00:00Z", "variants": { "edges": [ { "node": { "displayName": "Draft - 151cm" } } ] }, "variantsCount": { "count": 1 }, "vendor": "Arbor" } } } ### Get metafields attached to a product 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 ProductMetafields($ownerId: ID!) { product(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductMetafields($ownerId: ID!) {\n product(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/Product/108828309\"\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 ProductMetafields($ownerId: ID!) {\n product(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/Product/108828309\"\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 ProductMetafields($ownerId: ID!) {\n product(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/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductMetafields($ownerId: ID!) {\n product(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/Product/108828309" } #### Graphql Response { "data": { "product": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "liner_material", "value": "synthetic leather" } } ] } } } } ### Get pinned metafield definitions associated with a product 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 ProductMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { product(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/Product/108828309\",\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 ProductMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n product(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/Product/108828309\",\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 ProductMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n product(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/Product/108828309\",\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 ProductMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n product(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/Product/108828309\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n product(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/Product/108828309", "first": 10, "sortKey": "PINNED_POSITION" } #### Graphql Response { "data": { "product": { "metafieldDefinitions": { "edges": [ { "node": { "name": "Sole Material", "namespace": "my_fields", "key": "sole_material", "type": { "name": "single_line_text_field" } } }, { "node": { "name": "Liner Material", "namespace": "my_fields", "key": "liner_material", "type": { "name": "single_line_text_field" } } } ] } } } } ### Get the price range for a product for buyers from Canada 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 { product(id: \\\"gid://shopify/Product/108828309\\\") { contextualPricing(context: {country: CA}) { priceRange { maxVariantPrice { amount currencyCode } minVariantPrice { amount currencyCode } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/108828309\") {\n contextualPricing(context: {country: CA}) {\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\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 product(id: \"gid://shopify/Product/108828309\") {\n contextualPricing(context: {country: CA}) {\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\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 product(id: \"gid://shopify/Product/108828309\") {\n contextualPricing(context: {country: CA}) {\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/108828309\") {\n contextualPricing(context: {country: CA}) {\n priceRange {\n maxVariantPrice {\n amount\n currencyCode\n }\n minVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "contextualPricing": { "priceRange": { "maxVariantPrice": { "amount": "12.99", "currencyCode": "CAD" }, "minVariantPrice": { "amount": "12.99", "currencyCode": "CAD" } } } } } } ### Get the title, description and online store URL of a product 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 { product(id: \\\"gid://shopify/Product/108828309\\\") { title description onlineStoreUrl } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n description\n onlineStoreUrl\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n description\n onlineStoreUrl\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n description\n onlineStoreUrl\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n description\n onlineStoreUrl\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "title": "Draft", "description": "good board", "onlineStoreUrl": "https://www.snowdevil.ca/products/draft" } } } ### Get the total count of inventory in stock of a product 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 { product(id: \\\"gid://shopify/Product/108828309\\\") { title totalInventory } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n totalInventory\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n totalInventory\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n totalInventory\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n totalInventory\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "title": "Draft", "totalInventory": 1 } } } ### Loading translations and localizations of a product's title and description 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 TranslationsAndLocalizations { product(id: \\\"gid://shopify/Product/273955669\\\") { title descriptionHtml translations(locale: \\\"fr\\\") { key value } localizations: translations(locale: \\\"fr\\\", marketId: \\\"gid://shopify/Market/249692835\\\") { key value } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query TranslationsAndLocalizations {\n product(id: \"gid://shopify/Product/273955669\") {\n title\n descriptionHtml\n translations(locale: \"fr\") {\n key\n value\n }\n localizations: translations(locale: \"fr\", marketId: \"gid://shopify/Market/249692835\") {\n key\n value\n }\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 TranslationsAndLocalizations {\n product(id: \"gid://shopify/Product/273955669\") {\n title\n descriptionHtml\n translations(locale: \"fr\") {\n key\n value\n }\n localizations: translations(locale: \"fr\", marketId: \"gid://shopify/Market/249692835\") {\n key\n value\n }\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 TranslationsAndLocalizations {\n product(id: \"gid://shopify/Product/273955669\") {\n title\n descriptionHtml\n translations(locale: \"fr\") {\n key\n value\n }\n localizations: translations(locale: \"fr\", marketId: \"gid://shopify/Market/249692835\") {\n key\n value\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query TranslationsAndLocalizations {\n product(id: \"gid://shopify/Product/273955669\") {\n title\n descriptionHtml\n translations(locale: \"fr\") {\n key\n value\n }\n localizations: translations(locale: \"fr\", marketId: \"gid://shopify/Market/249692835\") {\n key\n value\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "title": "Wool sweater", "descriptionHtml": "

It is very warm!

", "translations": [ { "key": "body_html", "value": "

C’est très chaud!

" }, { "key": "title", "value": "Pull en laine" } ], "localizations": [ { "key": "title", "value": "Chandail en laine" } ] } } } ### Query a product and display its variants 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 { product(id: \\\"gid://shopify/Product/108828309\\\") { title variants(first: 10) { edges { node { selectedOptions { name value } media(first: 10) { edges { node { alt mediaContentType status __typename ... on MediaImage { id preview { image { originalSrc } } __typename } } } } } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n variants(first: 10) {\n edges {\n node {\n selectedOptions {\n name\n value\n }\n media(first: 10) {\n edges {\n node {\n alt\n mediaContentType\n status\n __typename\n ... on MediaImage {\n id\n preview {\n image {\n originalSrc\n }\n }\n __typename\n }\n }\n }\n }\n }\n }\n }\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n variants(first: 10) {\n edges {\n node {\n selectedOptions {\n name\n value\n }\n media(first: 10) {\n edges {\n node {\n alt\n mediaContentType\n status\n __typename\n ... on MediaImage {\n id\n preview {\n image {\n originalSrc\n }\n }\n __typename\n }\n }\n }\n }\n }\n }\n }\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n variants(first: 10) {\n edges {\n node {\n selectedOptions {\n name\n value\n }\n media(first: 10) {\n edges {\n node {\n alt\n mediaContentType\n status\n __typename\n ... on MediaImage {\n id\n preview {\n image {\n originalSrc\n }\n }\n __typename\n }\n }\n }\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n variants(first: 10) {\n edges {\n node {\n selectedOptions {\n name\n value\n }\n media(first: 10) {\n edges {\n node {\n alt\n mediaContentType\n status\n __typename\n ... on MediaImage {\n id\n preview {\n image {\n originalSrc\n }\n }\n __typename\n }\n }\n }\n }\n }\n }\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "title": "Draft", "variants": { "edges": [ { "node": { "selectedOptions": [ { "name": "Title", "value": "151cm" } ], "media": { "edges": [ { "node": { "alt": "", "mediaContentType": "IMAGE", "status": "READY", "__typename": "MediaImage", "id": "gid://shopify/MediaImage/853695510", "preview": { "image": { "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1730761095" } } } } ] } } } ] } } } } ### Query whether a product is published in a given country 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 { product(id: \\\"gid://shopify/Product/49527214\\\") { title publishedInCA: publishedInContext(context: {country: CA}) publishedInGB: publishedInContext(context: {country: GB}) publishedInUS: publishedInContext(context: {country: US}) } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/49527214\") {\n title\n publishedInCA: publishedInContext(context: {country: CA})\n publishedInGB: publishedInContext(context: {country: GB})\n publishedInUS: publishedInContext(context: {country: US})\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 product(id: \"gid://shopify/Product/49527214\") {\n title\n publishedInCA: publishedInContext(context: {country: CA})\n publishedInGB: publishedInContext(context: {country: GB})\n publishedInUS: publishedInContext(context: {country: US})\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 product(id: \"gid://shopify/Product/49527214\") {\n title\n publishedInCA: publishedInContext(context: {country: CA})\n publishedInGB: publishedInContext(context: {country: GB})\n publishedInUS: publishedInContext(context: {country: US})\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/49527214\") {\n title\n publishedInCA: publishedInContext(context: {country: CA})\n publishedInGB: publishedInContext(context: {country: GB})\n publishedInUS: publishedInContext(context: {country: US})\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "title": "Alarm clock", "publishedInCA": true, "publishedInGB": false, "publishedInUS": true } } } ### Receive a count of all Product Images 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 ProductImageCount($productId: ID!) { product(id: $productId) { mediaCount { count } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductImageCount($productId: ID!) {\n product(id: $productId) {\n mediaCount {\n count\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/108828309\"\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 ProductImageCount($productId: ID!) {\n product(id: $productId) {\n mediaCount {\n count\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/108828309\"\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 ProductImageCount($productId: ID!) {\n product(id: $productId) {\n mediaCount {\n count\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductImageCount($productId: ID!) {\n product(id: $productId) {\n mediaCount {\n count\n }\n }\n}" #### Graphql Input { "productId": "gid://shopify/Product/108828309" } #### Graphql Response { "data": { "product": { "mediaCount": { "count": 5 } } } } ### Receive a list of all Product Images 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 ProductImageList($productId: ID!) { product(id: $productId) { media(first: 10, query: \\\"media_type:IMAGE\\\", sortKey: POSITION) { nodes { id alt ... on MediaImage { createdAt image { width height url } } } pageInfo { startCursor endCursor } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductImageList($productId: ID!) {\n product(id: $productId) {\n media(first: 10, query: \"media_type:IMAGE\", sortKey: POSITION) {\n nodes {\n id\n alt\n ... on MediaImage {\n createdAt\n image {\n width\n height\n url\n }\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/108828309\"\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 ProductImageList($productId: ID!) {\n product(id: $productId) {\n media(first: 10, query: \"media_type:IMAGE\", sortKey: POSITION) {\n nodes {\n id\n alt\n ... on MediaImage {\n createdAt\n image {\n width\n height\n url\n }\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/108828309\"\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 ProductImageList($productId: ID!) {\n product(id: $productId) {\n media(first: 10, query: \"media_type:IMAGE\", sortKey: POSITION) {\n nodes {\n id\n alt\n ... on MediaImage {\n createdAt\n image {\n width\n height\n url\n }\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductImageList($productId: ID!) {\n product(id: $productId) {\n media(first: 10, query: \"media_type:IMAGE\", sortKey: POSITION) {\n nodes {\n id\n alt\n ... on MediaImage {\n createdAt\n image {\n width\n height\n url\n }\n }\n }\n pageInfo {\n startCursor\n endCursor\n }\n }\n }\n}" #### Graphql Input { "productId": "gid://shopify/Product/108828309" } #### Graphql Response { "data": { "product": { "media": { "nodes": [ { "id": "gid://shopify/MediaImage/853695510", "alt": "", "createdAt": "2024-11-04T22:58:15Z", "image": { "width": 85, "height": 400, "url": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1730761095" } }, { "id": "gid://shopify/MediaImage/603944694", "alt": "", "createdAt": "2024-11-04T22:58:15Z", "image": { "width": 85, "height": 400, "url": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft59.jpg?v=1730761095" } } ], "pageInfo": { "startCursor": "eyJsYXN0X2lkIjo4NTM2OTU1MTAsImxhc3RfdmFsdWUiOiI0In0=", "endCursor": "eyJsYXN0X2lkIjo2MDM5NDQ2OTQsImxhc3RfdmFsdWUiOiI1In0=" } } } } } ### Retrieve a single product 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 GetProduct($id: ID!) { product(id: $id) { id title variants(first: 10) { nodes { id title } } collections(first: 10) { nodes { id title } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetProduct($id: ID!) {\n product(id: $id) {\n id\n title\n variants(first: 10) {\n nodes {\n id\n title\n }\n }\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/Product/108828309\"\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 GetProduct($id: ID!) {\n product(id: $id) {\n id\n title\n variants(first: 10) {\n nodes {\n id\n title\n }\n }\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/Product/108828309\"\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 GetProduct($id: ID!) {\n product(id: $id) {\n id\n title\n variants(first: 10) {\n nodes {\n id\n title\n }\n }\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetProduct($id: ID!) {\n product(id: $id) {\n id\n title\n variants(first: 10) {\n nodes {\n id\n title\n }\n }\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n}" #### Graphql Input { "id": "gid://shopify/Product/108828309" } #### Graphql Response { "data": { "product": { "id": "gid://shopify/Product/108828309", "title": "Draft", "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/43729076", "title": "151cm" } ] }, "collections": { "nodes": [ { "id": "gid://shopify/Collection/79210309", "title": "Custom Other Items" }, { "id": "gid://shopify/Collection/94229130", "title": "All products more expensive than free" }, { "id": "gid://shopify/Collection/142458073", "title": "All snowboards" }, { "id": "gid://shopify/Collection/442946009", "title": "All products - handpicked!" }, { "id": "gid://shopify/Collection/793607630", "title": "Featured items" }, { "id": "gid://shopify/Collection/925420914", "title": "All snowboards called Draft" }, { "id": "gid://shopify/Collection/1007901140", "title": "Featured items" }, { "id": "gid://shopify/Collection/1063001310", "title": "Smart Other items" } ] } } } } ### Retrieve media objects 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 { product(id: \\\"gid://shopify/Product/108828309\\\") { title media(first: 5) { edges { node { ...fieldsForMediaTypes } } } } } fragment fieldsForMediaTypes on Media { alt mediaContentType preview { image { id altText originalSrc } } status ... on Video { id sources { format height mimeType url width } originalSource { format height mimeType url width } } ... on ExternalVideo { id host embeddedUrl } ... on Model3d { sources { format mimeType url } originalSource { format mimeType url } } ... on MediaImage { id image { altText originalSrc } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n media(first: 5) {\n edges {\n node {\n ...fieldsForMediaTypes\n }\n }\n }\n }\n }\n \n fragment fieldsForMediaTypes on Media {\n alt\n mediaContentType\n preview {\n image {\n id\n altText\n originalSrc\n }\n }\n status\n ... on Video {\n id\n sources {\n format\n height\n mimeType\n url\n width\n }\n originalSource {\n format\n height\n mimeType\n url\n width\n }\n }\n ... on ExternalVideo {\n id\n host\n embeddedUrl\n }\n ... on Model3d {\n sources {\n format\n mimeType\n url\n }\n originalSource {\n format\n mimeType\n url\n }\n }\n ... on MediaImage {\n id\n image {\n altText\n originalSrc\n }\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n media(first: 5) {\n edges {\n node {\n ...fieldsForMediaTypes\n }\n }\n }\n }\n }\n \n fragment fieldsForMediaTypes on Media {\n alt\n mediaContentType\n preview {\n image {\n id\n altText\n originalSrc\n }\n }\n status\n ... on Video {\n id\n sources {\n format\n height\n mimeType\n url\n width\n }\n originalSource {\n format\n height\n mimeType\n url\n width\n }\n }\n ... on ExternalVideo {\n id\n host\n embeddedUrl\n }\n ... on Model3d {\n sources {\n format\n mimeType\n url\n }\n originalSource {\n format\n mimeType\n url\n }\n }\n ... on MediaImage {\n id\n image {\n altText\n originalSrc\n }\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 product(id: \"gid://shopify/Product/108828309\") {\n title\n media(first: 5) {\n edges {\n node {\n ...fieldsForMediaTypes\n }\n }\n }\n }\n }\n \n fragment fieldsForMediaTypes on Media {\n alt\n mediaContentType\n preview {\n image {\n id\n altText\n originalSrc\n }\n }\n status\n ... on Video {\n id\n sources {\n format\n height\n mimeType\n url\n width\n }\n originalSource {\n format\n height\n mimeType\n url\n width\n }\n }\n ... on ExternalVideo {\n id\n host\n embeddedUrl\n }\n ... on Model3d {\n sources {\n format\n mimeType\n url\n }\n originalSource {\n format\n mimeType\n url\n }\n }\n ... on MediaImage {\n id\n image {\n altText\n originalSrc\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n product(id: \"gid://shopify/Product/108828309\") {\n title\n media(first: 5) {\n edges {\n node {\n ...fieldsForMediaTypes\n }\n }\n }\n }\n}\n\nfragment fieldsForMediaTypes on Media {\n alt\n mediaContentType\n preview {\n image {\n id\n altText\n originalSrc\n }\n }\n status\n ... on Video {\n id\n sources {\n format\n height\n mimeType\n url\n width\n }\n originalSource {\n format\n height\n mimeType\n url\n width\n }\n }\n ... on ExternalVideo {\n id\n host\n embeddedUrl\n }\n ... on Model3d {\n sources {\n format\n mimeType\n url\n }\n originalSource {\n format\n mimeType\n url\n }\n }\n ... on MediaImage {\n id\n image {\n altText\n originalSrc\n }\n }\n}" #### Graphql Input null #### Graphql Response { "data": { "product": { "title": "Draft", "media": { "edges": [ { "node": { "alt": "This is a video", "mediaContentType": "EXTERNAL_VIDEO", "preview": { "image": { "id": "gid://shopify/ImageSource/425689044", "altText": "This is a video", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/external_video_preview.jpg?v=1730761095" } }, "status": "READY", "id": "gid://shopify/ExternalVideo/1041834415", "host": "YOUTUBE", "embeddedUrl": "https://youtu.be/dQw4w9WgXcQ" } }, { "node": { "alt": "This is a video", "mediaContentType": "VIDEO", "preview": { "image": { "id": "gid://shopify/ImageSource/727549632", "altText": "This is a video", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/shopify_video_preview.jpg?v=1730761095" } }, "status": "READY", "id": "gid://shopify/Video/723685877", "sources": [ { "format": "mp4", "height": 1080, "mimeType": "video/mp4", "url": "https://cdn.shopify.com/videos/dev/vp/098dc4345e654352a24b0b033d2a3a1b/HD-1080p.mp4", "width": 1920 }, { "format": "mp4", "height": 720, "mimeType": "video/mp4", "url": "https://cdn.shopify.com/videos/dev/vp/098dc4345e654352a24b0b033d2a3a1b/HD-720p.mp4", "width": 1280 }, { "format": "m3u8", "height": 720, "mimeType": "application/x-mpegURL", "url": "https://cdn.shopify.com/videos/dev/vp/098dc4345e654352a24b0b033d2a3a1b/streaming.m3u8", "width": 1280 } ], "originalSource": { "format": "mov", "height": 360, "mimeType": "video/quicktime", "url": "https://cdn.shopify.com/videos/vp/03d15b89f02b4e1a97e9c5cd76bd0a6d/SD-360p.mov", "width": 480 } } }, { "node": { "alt": "This is a 3d Model", "mediaContentType": "MODEL_3D", "preview": { "image": { "id": "gid://shopify/ImageSource/175601098", "altText": "This is a 3d Model", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/threed_preview_image.jpg?v=1730761095" } }, "status": "READY", "sources": [ { "format": "glb", "mimeType": "model/gltf-binary", "url": "https://storage.googleapis.com/threed-models-test/temp.glb" }, { "format": "usdz", "mimeType": "model/vnd.usdz+zip", "url": "https://storage.googleapis.com/threed-models-test/temp.usdz" } ], "originalSource": { "format": "glb", "mimeType": "model/gltf-binary", "url": "https://storage.googleapis.com/threed-models-test/temp_original.glb" } } }, { "node": { "alt": "", "mediaContentType": "IMAGE", "preview": { "image": { "id": "gid://shopify/ImageSource/853695510", "altText": "", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1730761095" } }, "status": "READY", "id": "gid://shopify/MediaImage/853695510", "image": { "altText": "", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1730761095" } } }, { "node": { "alt": "", "mediaContentType": "IMAGE", "preview": { "image": { "id": "gid://shopify/ImageSource/603944694", "altText": "", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft59.jpg?v=1730761095" } }, "status": "READY", "id": "gid://shopify/MediaImage/603944694", "image": { "altText": "", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft59.jpg?v=1730761095" } } } ] } } } } ### Retrieves a list 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 CollectionsForProduct($productId: ID!) { product(id: $productId) { collections(first: 10) { nodes { id title } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/108828309\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query CollectionsForProduct($productId: ID!) {\n product(id: $productId) {\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/108828309\"\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 CollectionsForProduct($productId: ID!) {\n product(id: $productId) {\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/108828309\"\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 CollectionsForProduct($productId: ID!) {\n product(id: $productId) {\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/108828309\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query CollectionsForProduct($productId: ID!) {\n product(id: $productId) {\n collections(first: 10) {\n nodes {\n id\n title\n }\n }\n }\n}" #### Graphql Input { "productId": "gid://shopify/Product/108828309" } #### Graphql Response { "data": { "product": { "collections": { "nodes": [ { "id": "gid://shopify/Collection/79210309", "title": "Custom Other Items" }, { "id": "gid://shopify/Collection/94229130", "title": "All products more expensive than free" }, { "id": "gid://shopify/Collection/142458073", "title": "All snowboards" }, { "id": "gid://shopify/Collection/442946009", "title": "All products - handpicked!" }, { "id": "gid://shopify/Collection/793607630", "title": "Featured items" }, { "id": "gid://shopify/Collection/925420914", "title": "All snowboards called Draft" }, { "id": "gid://shopify/Collection/1007901140", "title": "Featured items" }, { "id": "gid://shopify/Collection/1063001310", "title": "Smart Other items" } ] } } } }