--- title: productVariant - GraphQL Admin description: >- Retrieves a [product variant](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) by its ID. A product variant is a specific version of a [product](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) that comes in more than one [option](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOption), such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. Use the `productVariant` query when you need to: - Access essential product variant data (for example, title, price, image, and metafields). - Build product detail pages and manage inventory. - Handle international sales with localized pricing and content. - Manage product variants that are part of a bundle or selling plan. Learn more about working with [Shopify's product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components). api_version: 2025-10 api_name: admin type: query api_type: graphql source_url: html: 'https://shopify.dev/docs/api/admin-graphql/latest/queries/productVariant' md: 'https://shopify.dev/docs/api/admin-graphql/latest/queries/productVariant.md' --- # product​Variant query Retrieves a [product variant](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) by its ID. A product variant is a specific version of a [product](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) that comes in more than one [option](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOption), such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. Use the `productVariant` query when you need to: * Access essential product variant data (for example, title, price, image, and metafields). * Build product detail pages and manage inventory. * Handle international sales with localized pricing and content. * Manage product variants that are part of a bundle or selling plan. Learn more about working with [Shopify's product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components). ## Arguments * id [ID!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) required The ID of the `ProductVariant` to return. *** ## Possible returns * Product​Variant [Product​Variant](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariant) The `ProductVariant` object represents a version of a [product](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) that comes in more than one [option](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductOption), such as size or color. For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one product variant and a large, blue t-shirt would be another. Use the `ProductVariant` object to manage the full lifecycle and configuration of a product's variants. Common use cases for using the `ProductVariant` object include: * Tracking inventory for each variant * Setting unique prices for each variant * Assigning barcodes and SKUs to connect variants to fulfillment services * Attaching variant-specific images and media * Setting delivery and tax requirements * Supporting product bundles, subscriptions, and selling plans A `ProductVariant` is associated with a parent [`Product`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) object. `ProductVariant` serves as the central link between a product's merchandising configuration, inventory, pricing, fulfillment, and sales channels within the GraphQL Admin API schema. Each variant can reference other GraphQL types such as: * [`InventoryItem`](https://shopify.dev/docs/api/admin-graphql/latest/objects/InventoryItem): Used for inventory tracking * [`Image`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Image): Used for variant-specific images * [`SellingPlanGroup`](https://shopify.dev/docs/api/admin-graphql/latest/objects/SellingPlanGroup): Used for subscriptions and selling plans Learn more about [Shopify's product model](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model/product-model-components). * available​For​Sale [Boolean!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Boolean) non-null Whether the product variant is available for sale. * barcode [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The value of the barcode associated with the product. * compare​At​Price [Money](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Money) The compare-at price of the variant in the default shop currency. * contextual​Pricing [Product​Variant​Contextual​Pricing!](https://shopify.dev/docs/api/admin-graphql/latest/objects/ProductVariantContextualPricing) non-null The pricing that applies for a customer in a given context. As of API version 2025-04, only active markets are considered in the price resolution. * context [Contextual​Pricing​Context!](https://shopify.dev/docs/api/admin-graphql/latest/input-objects/ContextualPricingContext) required ### Arguments The context used to generate contextual pricing for the variant. *** * created​At [Date​Time!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/DateTime) non-null The date and time when the variant was created. * default​Cursor [String!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) non-null A default [cursor](https://shopify.dev/api/usage/pagination-graphql) that returns the single next record, sorted ascending by ID. * delivery​Profile [Delivery​Profile](https://shopify.dev/docs/api/admin-graphql/latest/objects/DeliveryProfile) The [delivery profile](https://shopify.dev/api/admin-graphql/latest/objects/DeliveryProfile) for the variant. * display​Name [String!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) non-null Display name of the variant, based on product's title + variant's title. * events [Event​Connection!](https://shopify.dev/docs/api/admin-graphql/latest/connections/EventConnection) non-null The paginated list of events associated with the host subject. * first [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Boolean) Default:false Reverse the order of the underlying list. * sort​Key [Event​Sort​Keys](https://shopify.dev/docs/api/admin-graphql/latest/enums/EventSortKeys) Default:ID Sort the underlying list using a key. If your query is slow or returns an error, then [try specifying a sort key that matches the field used in the search](https://shopify.dev/api/usage/pagination-graphql#search-performance-considerations). * query [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * action string * comments boolean * created\_at time * id id * subject\_type string - The action that occured. - Example: * `action:create` Whether or not to include [comment-events](https://shopify.dev/api/admin-graphql/latest/objects/CommentEvent) in your search, passing `false` will exclude comment-events, any other value will include comment-events. - Example: * `false` * `true` Filter by the date and time when the event happened. - Example: * `created_at:>2020-10-21` * `created_at:=1234` * `id:<=1234` The resource type affected by this event. See [EventSubjectType](https://shopify.dev/api/admin-graphql/latest/enums/EventSubjectType) for possible values. Example: * `PRODUCT_VARIANT` * `PRODUCT` * `COLLECTION` *** * id [ID!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/ID) non-null A globally-unique ID. * inventory​Item [Inventory​Item!](https://shopify.dev/docs/api/admin-graphql/latest/objects/InventoryItem) non-null The inventory item, which is used to query for inventory information. * inventory​Policy [Product​Variant​Inventory​Policy!](https://shopify.dev/docs/api/admin-graphql/latest/enums/ProductVariantInventoryPolicy) non-null Whether customers are allowed to place an order for the product variant when it's out of stock. * inventory​Quantity [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The total sellable quantity of the variant. * legacy​Resource​Id [Unsigned​Int64!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/UnsignedInt64) non-null The ID of the corresponding resource in the REST Admin API. * media [Media​Connection!](https://shopify.dev/docs/api/admin-graphql/latest/connections/MediaConnection) non-null The media associated with the product variant. * first [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * metafield [Metafield](https://shopify.dev/docs/api/admin-graphql/latest/objects/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. * namespace [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) ### Arguments The container the metafield belongs to. If omitted, the app-reserved namespace will be used. * key [String!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) required The key for the metafield. *** * metafields [Metafield​Connection!](https://shopify.dev/docs/api/admin-graphql/latest/connections/MetafieldConnection) non-null A list of [custom fields](https://shopify.dev/docs/apps/build/custom-data) that a merchant associates with a Shopify resource. * namespace [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) ### Arguments The metafield namespace to filter by. If omitted, the app-reserved namespace will be used. * keys [\[String!\]](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) List of keys of metafields in the format `namespace.key`, will be returned in the same format. * first [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Boolean) Default:false Reverse the order of the underlying list. *** * position [Int!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) non-null The order of the product variant in the list of product variants. The first position in the list is 1. * price [Money!](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Money) non-null The price of the product variant in the default shop currency. * product [Product!](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) non-null The product that this variant belongs to. * product​Parents [Product​Connection!](https://shopify.dev/docs/api/admin-graphql/latest/connections/ProductConnection) non-null A list of products that have product variants that contain this variant as a product component. * first [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) ### Arguments The first `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * after [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come after the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * last [Int](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Int) The last `n` elements from the [paginated list](https://shopify.dev/api/usage/pagination-graphql). * before [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) The elements that come before the specified [cursor](https://shopify.dev/api/usage/pagination-graphql). * reverse [Boolean](https://shopify.dev/docs/api/admin-graphql/latest/scalars/Boolean) Default:false Reverse the order of the underlying list. * query [String](https://shopify.dev/docs/api/admin-graphql/latest/scalars/String) A filter made up of terms, connectives, modifiers, and comparators. You can apply one or more filters to a query. Learn more about [Shopify API search syntax](https://shopify.dev/api/usage/search-syntax). * * default string * barcode string * bundles boolean * category\_id string * collection\_id id * combined\_listing\_role string * created\_at time * delivery\_profile\_id id * error\_feedback string - Filter by a case-insensitive search of multiple fields in a document. - Example: * `query=Bob Norman` * `query=title:green hoodie` Filter by the product variant [`barcode`](https://shopify.dev/api/admin-graphql/latest/objects/ProductVariant#field-barcode) field. - Example: * `barcode:ABC-abc-1234` Filter by a [product bundle](https://shopify.dev/docs/apps/build/product-merchandising/bundles). A product bundle is a set of two or more related products, which are commonly offered at a discount. - Example: * `bundles:true` Filter by the product [category ID](https://shopify.dev/api/admin-graphql/latest/objects/Product#field-category) (`product.category.id`). A product category is 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). - Example: * `category_id:sg-4-17-2-17` Filter by the collection [`id`](https://shopify.dev/api/admin-graphql/latest/objects/Collection#field-id) field. - Example: * `collection_id:108179161409` Filter by the role of the product in a [combined listing](https://shopify.dev/apps/build/product-merchandising/combined-listings). - Valid values: * `parent` * `child` * `no_role` Example: * `combined_listing_role:parent` Filter by the date and time when the product was created. - Example: * `created_at:>'2020-10-21T23:39:20Z'` * `created_at:=1234` * `id:<=1234` Filter by inventory count. - Example: * `inventory_total:0` * `inventory_total:>150` * `inventory_total:>=200` Filter by products that have a reduced price. For more information, refer to the [`CollectionRule`](https://shopify.dev/api/admin-graphql/latest/objects/CollectionRule) object. - Example: * `is_price_reduced:true` Filters resources by metafield value. Format: `metafields.{namespace}.{key}:{value}`. Learn more about [querying by metafield value](https://shopify.dev/apps/build/custom-data/metafields/query-by-metafield-value). - Example: * `metafields.custom.on_sale:true` * `metafields.product.material:"gid://shopify/Metaobject/43458085"` Filter by products that are out of stock in at least one location. - Example: * `out_of_stock_somewhere:true` Filter by the product variant [`price`](https://shopify.dev/api/admin-graphql/latest/objects/Productvariant#field-price) field. - Example: * `price:100.57` Filter by the app [`id`](https://shopify.dev/api/admin-graphql/latest/objects/App#field-id) field. - Example: * `product_configuration_owner:10001` Filter by the publication status of the resource on a channel, such as the online store. The value is a composite of the [channel `app` ID](https://shopify.dev/api/admin-graphql/latest/objects/Channel#app-price) (`Channel.app.id`) and one of the valid values. - Valid values: * `approved` * `rejected` * `needs_action` * `awaiting_review` * `published` * `demoted` * `scheduled` * `provisionally_published` Example: * `product_publication_status:189769876-approved` Filter by a comma-separated list of [product types](https://help.shopify.com/manual/products/details/product-type). - Example: * `product_type:snowboard` Filter by a comma-separated list of publication IDs that are associated with the product. - Example: * `publication_ids:184111530305,184111694145` Filter by the publishable status of the resource on a channel, such as the online store. The value is a composite of either the [channel `app` ID](https://shopify.dev/api/admin-graphql/latest/objects/Channel#app-price) (`Channel.app.id`) or [channel `name`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Channel#field-name) and one of the valid values. - Valid values: * `online_store_channel` * `published` * `unpublished` * `visible` * `unavailable` * `hidden` * `intended` * `visible` Example: * `publishable_status:published` * `publishable_status:189769876-visible` * `publishable_status:pos-hidden` Filter by the date and time when the product was published to the online store and other sales channels. - Example: * `published_at:>2020-10-21T23:39:20Z` * `published_at:'2020-10-21T23:39:20Z'` * `updated_at:2020-10-21T23:39:20Z` * `created_at:=1234` * `id:<=1234` Filter by the metafield definition [`key`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-key) field. - Example: * `key:some-key` Filter by the metafield definition [`namespace`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-namespace) field. - Example: * `namespace:some-namespace` Filter by the metafield definition [`ownerType`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-ownertype) field. - Example: * `owner_type:PRODUCT` Filter by the metafield definition [`type`](https://shopify.dev/docs/api/admin-graphql/latest/objects/MetafieldDefinition#field-type) field. - Example: * `type:single_line_text_field` Filter by the date and time when the metafield definition was last updated. Example: * `updated_at:>2020-10-21T23:39:20Z` * `updated_at: { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }`, { variables: { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } } QUERY variables = { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }`, "variables": { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" }, }, }); ``` #### Response ```json { "productVariant": { "linerMaterial": { "value": "synthetic leather" } } } ``` * ### Retrieve a product variant's price for buyers in Canada #### Description Use the \`contextualPricing\` field to retrieve a product variant's price for buyers in Canada. Prices are returned in the currency configured for the country in \[Markets settings]\(https://help.shopify.com/manual/international/managing). They might be calculated from the base variant prices, or provided by the merchant as fixed local prices. #### Query ```graphql query { productVariant(id: "gid://shopify/ProductVariant/43729076") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { productVariant(id: \"gid://shopify/ProductVariant/43729076\") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { productVariant(id: "gid://shopify/ProductVariant/43729076") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }`, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query { productVariant(id: "gid://shopify/ProductVariant/43729076") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { productVariant(id: "gid://shopify/ProductVariant/43729076") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }`, }); ``` #### Response ```json { "productVariant": { "contextualPricing": { "price": { "amount": "12.99", "currencyCode": "CAD" } } } } ``` * ### Retrieve a product variant's price in different countries #### Description Use the \`contextualPricing\` field to retrieve a product variant's price in Canada, France, and the United States. This example returns the price of the product variant in each country. #### Query ```graphql query { productVariant(id: "gid://shopify/ProductVariant/43729076") { CanadaPrice: contextualPricing(context: {country: CA}) { price { amount currencyCode } } USPrice: contextualPricing(context: {country: US}) { price { amount currencyCode } } FrancePrice: contextualPricing(context: {country: FR}) { price { amount currencyCode } } } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { productVariant(id: \"gid://shopify/ProductVariant/43729076\") { CanadaPrice: contextualPricing(context: {country: CA}) { price { amount currencyCode } } USPrice: contextualPricing(context: {country: US}) { price { amount currencyCode } } FrancePrice: contextualPricing(context: {country: FR}) { price { amount currencyCode } } } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { productVariant(id: "gid://shopify/ProductVariant/43729076") { CanadaPrice: contextualPricing(context: {country: CA}) { price { amount currencyCode } } USPrice: contextualPricing(context: {country: US}) { price { amount currencyCode } } FrancePrice: contextualPricing(context: {country: FR}) { price { amount currencyCode } } } }`, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query { productVariant(id: "gid://shopify/ProductVariant/43729076") { CanadaPrice: contextualPricing(context: {country: CA}) { price { amount currencyCode } } USPrice: contextualPricing(context: {country: US}) { price { amount currencyCode } } FrancePrice: contextualPricing(context: {country: FR}) { price { amount currencyCode } } } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { productVariant(id: "gid://shopify/ProductVariant/43729076") { CanadaPrice: contextualPricing(context: {country: CA}) { price { amount currencyCode } } USPrice: contextualPricing(context: {country: US}) { price { amount currencyCode } } FrancePrice: contextualPricing(context: {country: FR}) { price { amount currencyCode } } } }`, }); ``` #### Response ```json { "productVariant": { "CanadaPrice": { "price": { "amount": "12.99", "currencyCode": "CAD" } }, "USPrice": { "price": { "amount": "10.0", "currencyCode": "USD" } }, "FrancePrice": { "price": { "amount": "4.95", "currencyCode": "EUR" } } } } ``` * ### Retrieve information about a product variant by its ID #### Description Retrieve information about a product variant by its ID. This example returns details including the title, price, and barcode of the product variant. #### Query ```graphql query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } } ``` #### Variables ```json { "id": "gid://shopify/ProductVariant/43729076" } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } }", "variables": { "id": "gid://shopify/ProductVariant/43729076" } }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } }`, { variables: { "id": "gid://shopify/ProductVariant/43729076" }, }, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } } QUERY variables = { "id": "gid://shopify/ProductVariant/43729076" } response = client.query(query: query, variables: variables) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } }`, "variables": { "id": "gid://shopify/ProductVariant/43729076" }, }, }); ``` #### Response ```json { "productVariant": { "id": "gid://shopify/ProductVariant/43729076", "title": "151cm", "availableForSale": true, "barcode": "12345678", "compareAtPrice": "20.00", "createdAt": "2025-06-11T00:27:43Z" } } ``` * ### Retrieve multiple product variants using their IDs and GraphQL aliases #### Description Retrieve multiple product variants by their IDs using \[aliases]\(https://shopify.dev/docs/apps/build/graphql/basics/advanced#make-multiple-queries-in-one-request) to name the results. This example returns the ID and title for each product variant. #### Query ```graphql query { productVariant1: productVariant(id: "gid://shopify/ProductVariant/30322695") { id title } productVariant2: productVariant(id: "gid://shopify/ProductVariant/43729076") { id title } productVariant3: productVariant(id: "gid://shopify/ProductVariant/113711323") { id title } } ``` #### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query { productVariant1: productVariant(id: \"gid://shopify/ProductVariant/30322695\") { id title } productVariant2: productVariant(id: \"gid://shopify/ProductVariant/43729076\") { id title } productVariant3: productVariant(id: \"gid://shopify/ProductVariant/113711323\") { id title } }" }' ``` #### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query { productVariant1: productVariant(id: "gid://shopify/ProductVariant/30322695") { id title } productVariant2: productVariant(id: "gid://shopify/ProductVariant/43729076") { id title } productVariant3: productVariant(id: "gid://shopify/ProductVariant/113711323") { id title } }`, ); const json = await response.json(); return json.data; } ``` #### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query { productVariant1: productVariant(id: "gid://shopify/ProductVariant/30322695") { id title } productVariant2: productVariant(id: "gid://shopify/ProductVariant/43729076") { id title } productVariant3: productVariant(id: "gid://shopify/ProductVariant/113711323") { id title } } QUERY response = client.query(query: query) ``` #### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: `query { productVariant1: productVariant(id: "gid://shopify/ProductVariant/30322695") { id title } productVariant2: productVariant(id: "gid://shopify/ProductVariant/43729076") { id title } productVariant3: productVariant(id: "gid://shopify/ProductVariant/113711323") { id title } }`, }); ``` #### Response ```json { "productVariant1": { "id": "gid://shopify/ProductVariant/30322695", "title": "151cm" }, "productVariant2": { "id": "gid://shopify/ProductVariant/43729076", "title": "151cm" }, "productVariant3": { "id": "gid://shopify/ProductVariant/113711323", "title": "155cm" } } ``` [Open in GraphiQL](http://localhost:3457/graphiql?query=query%20ProductVariantMetafield\(%24namespace%3A%20String!%2C%20%24key%3A%20String!%2C%20%24ownerId%3A%20ID!\)%20%7B%0A%20%20productVariant\(id%3A%20%24ownerId\)%20%7B%0A%20%20%20%20linerMaterial%3A%20metafield\(namespace%3A%20%24namespace%2C%20key%3A%20%24key\)%20%7B%0A%20%20%20%20%20%20value%0A%20%20%20%20%7D%0A%20%20%7D%0A%7D\&variables=%7B%0A%20%20%22namespace%22%3A%20%22my_fields%22%2C%0A%20%20%22key%22%3A%20%22liner_material%22%2C%0A%20%20%22ownerId%22%3A%20%22gid%3A%2F%2Fshopify%2FProductVariant%2F43729076%22%0A%7D) ##### GQL ```graphql query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } } ``` ##### cURL ```bash curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-10/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }", "variables": { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" } }' ``` ##### React Router ```javascript import { authenticate } from "../shopify.server"; export const loader = async ({request}) => { const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }`, { variables: { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" }, }, ); const json = await response.json(); return json.data; } ``` ##### Node.js ```javascript const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }`, "variables": { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" }, }, }); ``` ##### Ruby ```ruby session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } } QUERY variables = { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" } response = client.query(query: query, variables: variables) ``` ## Input variables JSON ```json { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" } ``` ## Response JSON ```json { "productVariant": { "linerMaterial": { "value": "synthetic leather" } } } ```