product Variantquery
query
2024-10latest
Returns a ProductVariant resource by ID.
Arguments
The ID of the ProductVariant to return.
Was this section helpful?
ProductVariant possible returns
Represents a product variant.
Was this section helpful?
Code examples for QUERY: productVariant
Query Reference for QUERY: productVariant
"{\n productVariant(id) {\n # ProductVariant fields\n }\n}"
Input Reference for QUERY: productVariant
Schema Reference for QUERY: productVariant
Display Examples for QUERY: productVariant
[ { "example": { "type_name": "productvariant", "title": "Get the price for a product variant for buyers in Canada", "description": "The following query returns the product variant’s price for buyers from Canada. These prices are returned in the currency configured for the country in Markets settings. They may be calculated from the base variant prices, or provided by the merchant as fixed local prices.", "query_string": "query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}", "query_arguments": { "id": "gid://shopify/ProductVariant/43729076" }, "response": { "data": { "productVariant": { "contextualPricing": { "price": { "amount": "12.99", "currencyCode": "CAD" } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/product_variant_test.rb", "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 { productVariant(id: \\\"gid://shopify/ProductVariant/43729076\\\") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\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 productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the ProductVariant to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/ProductVariant/43729076\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "productvariant", "title": "Get the price for a product variant for different countries in the same request", "description": "The following query returns the product variant’s price for buyers from Canada, France, and USA.", "query_string": "query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}", "query_arguments": { "id": "gid://shopify/ProductVariant/43729076" }, "response": { "data": { "productVariant": { "CanadaPrice": { "price": { "amount": "12.99", "currencyCode": "CAD" } }, "USPrice": { "price": { "amount": "10.0", "currencyCode": "USD" } }, "FrancePrice": { "price": { "amount": "4.95", "currencyCode": "EUR" } } } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/product_variant_test.rb", "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 { 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 } } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\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 productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n CanadaPrice: contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n USPrice: contextualPricing(context: {country: US}) {\n price {\n amount\n currencyCode\n }\n }\n FrancePrice: contextualPricing(context: {country: FR}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the ProductVariant to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/ProductVariant/43729076\"", "typeKind": "QUERY" } ] }, { "example": { "type_name": "productvariant", "title": "Retrieve information for non-existent variant ID", "description": "Trying to retrieve a product variant by an ID that doesn't exist returns `null`.\n", "query_string": "query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}", "query_arguments": { "id": "gid://shopify/ProductVariant/-1" }, "response": { "data": { "productVariant": null } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/merchandising/test/unit/graph_api/admin/product_variant_test.rb", "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 { productVariant(id: \\\"gid://shopify/ProductVariant/-1\\\") { contextualPricing(context: {country: CA}) { price { amount currencyCode } } } }\"\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\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 productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY\n\nresponse = client.query(query: query)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }`,\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n }\nQUERY;\n\n$response = $client->query([\"query\" => $query]);\n" }, "titleStringKey": "arguments", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the ProductVariant to return.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null }, "key": "id", "argValue": " \"gid://shopify/ProductVariant/-1\"", "typeKind": "QUERY" } ] } ]