Version: 2024-10
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
response: { "data": { "node": { "id": "gid://shopify/Product/108828309", "title": "Draft" } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
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" } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
response: { "data": { "product": { "contextualPricing": { "priceRange": { "maxVariantPrice": { "amount": "12.99", "currencyCode": "CAD" }, "minVariantPrice": { "amount": "12.99", "currencyCode": "CAD" } } } } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
response: { "data": { "product": { "title": "Draft", "description": "good board", "onlineStoreUrl": "https://www.snowdevil.ca/products/draft" } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
response: { "data": { "product": { "title": "Draft", "totalInventory": 1 } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
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" } ] } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
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=1727471607" } } } } ] } } } ] } } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
response: { "data": { "product": { "title": "Alarm clock", "publishedInCA": true, "publishedInGB": false, "publishedInUS": true } } }
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" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<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}"
input: null
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=1727471607" } }, "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=1727471607" } }, "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=1727471607" } }, "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=1727471607" } }, "status": "READY", "id": "gid://shopify/MediaImage/853695510", "image": { "altText": "", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft58.jpg?v=1727471607" } } }, { "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=1727471607" } }, "status": "READY", "id": "gid://shopify/MediaImage/603944694", "image": { "altText": "", "originalSrc": "https://cdn.shopify.com/s/files/1/2637/1970/products/draft59.jpg?v=1727471607" } } } ] } } } }