Version: 2025-01
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) { productVariant(id: $ownerId) { linerMaterial: metafield(namespace: $namespace, key: $key) { value } } }\",\n \"variables\": {\n \"namespace\": \"my_fields\",\n \"key\": \"liner_material\",\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(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/ProductVariant/43729076\"\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 ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(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/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n }\nQUERY;\n\n$variables = [\n \"namespace\" => \"my_fields\",\n \"key\" => \"liner_material\",\n \"ownerId\" => \"gid://shopify/ProductVariant/43729076\",\n];\n\n$response = $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 ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(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/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductVariantMetafield($namespace: String!, $key: String!, $ownerId: ID!) {\n productVariant(id: $ownerId) {\n linerMaterial: metafield(namespace: $namespace, key: $key) {\n value\n }\n }\n}"
input: { "namespace": "my_fields", "key": "liner_material", "ownerId": "gid://shopify/ProductVariant/43729076" }
response: { "data": { "productVariant": { "linerMaterial": { "value": "synthetic leather" } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ProductVariantMetafields($ownerId: ID!) { productVariant(id: $ownerId) { metafields(first: 3) { edges { node { namespace key value } } } } }\",\n \"variables\": {\n \"ownerId\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query ProductVariantMetafields($ownerId: ID!) {\n productVariant(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/ProductVariant/43729076\"\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 ProductVariantMetafields($ownerId: ID!) {\n productVariant(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/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query ProductVariantMetafields($ownerId: ID!) {\n productVariant(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"ownerId\" => \"gid://shopify/ProductVariant/43729076\",\n];\n\n$response = $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 ProductVariantMetafields($ownerId: ID!) {\n productVariant(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/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductVariantMetafields($ownerId: ID!) {\n productVariant(id: $ownerId) {\n metafields(first: 3) {\n edges {\n node {\n namespace\n key\n value\n }\n }\n }\n }\n}"
input: { "ownerId": "gid://shopify/ProductVariant/43729076" }
response: { "data": { "productVariant": { "metafields": { "edges": [ { "node": { "namespace": "my_fields", "key": "liner_material", "value": "synthetic leather" } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) { productVariant(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/ProductVariant/43729076\",\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 ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(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/ProductVariant/43729076\",\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 ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(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/ProductVariant/43729076\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(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\n$variables = [\n \"pinnedStatus\" => \"PINNED\",\n \"ownerId\" => \"gid://shopify/ProductVariant/43729076\",\n \"first\" => 10,\n \"sortKey\" => \"PINNED_POSITION\",\n];\n\n$response = $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 ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(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/ProductVariant/43729076\",\n \"first\": 10,\n \"sortKey\": \"PINNED_POSITION\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query ProductVariantMetafieldDefinitions($ownerId: ID!, $first: Int, $pinnedStatus: MetafieldDefinitionPinnedStatus, $sortKey: MetafieldDefinitionSortKeys) {\n productVariant(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}"
input: { "pinnedStatus": "PINNED", "ownerId": "gid://shopify/ProductVariant/43729076", "first": 10, "sortKey": "PINNED_POSITION" }
response: { "data": { "productVariant": { "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" } } } ] } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/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" 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" 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" 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" 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" Graphql query: "query {\n productVariant(id: \"gid://shopify/ProductVariant/43729076\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}"
input: null
response: { "data": { "productVariant": { "contextualPricing": { "price": { "amount": "12.99", "currencyCode": "CAD" } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/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" 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" 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" 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" 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" Graphql query: "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}"
input: null
response: { "data": { "productVariant": { "CanadaPrice": { "price": { "amount": "12.99", "currencyCode": "CAD" } }, "USPrice": { "price": { "amount": "10.0", "currencyCode": "USD" } }, "FrancePrice": { "price": { "amount": "4.95", "currencyCode": "EUR" } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query GetProductVariant($id: ID!) { productVariant(id: $id) { id title availableForSale barcode compareAtPrice createdAt } }\",\n \"variables\": {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\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 GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/ProductVariant/43729076\",\n];\n\n$response = $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 GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/ProductVariant/43729076\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query GetProductVariant($id: ID!) {\n productVariant(id: $id) {\n id\n title\n availableForSale\n barcode\n compareAtPrice\n createdAt\n }\n}"
input: { "id": "gid://shopify/ProductVariant/43729076" }
response: { "data": { "productVariant": { "id": "gid://shopify/ProductVariant/43729076", "title": "151cm", "availableForSale": true, "barcode": "12345678", "compareAtPrice": "20.00", "createdAt": "2024-11-12T15:54:57Z" } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2025-01/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" 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" 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" 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" 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" Graphql query: "query {\n productVariant(id: \"gid://shopify/ProductVariant/-1\") {\n contextualPricing(context: {country: CA}) {\n price {\n amount\n currencyCode\n }\n }\n }\n}"
input: null
response: { "data": { "productVariant": null } }