Version: 2024-07
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { productByHandle(handle: \\\"there is no product with a handle like this\\\") { id title productType description vendor } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productByHandle(handle: \"there is no product with a handle like this\") {\n id\n title\n productType\n description\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 productByHandle(handle: \"there is no product with a handle like this\") {\n id\n title\n productType\n description\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\n query {\n productByHandle(handle: \"there is no product with a handle like this\") {\n id\n title\n productType\n description\n vendor\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 productByHandle(handle: \"there is no product with a handle like this\") {\n id\n title\n productType\n description\n vendor\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n productByHandle(handle: \"there is no product with a handle like this\") {\n id\n title\n productType\n description\n vendor\n }\n}"
input: null
response: { "data": { "productByHandle": null } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { productByHandle(handle: \\\"ipod-nano\\\") { id handle title productType description vendor priceRangeV2 { minVariantPrice { amount currencyCode } maxVariantPrice { amount currencyCode } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n productByHandle(handle: \"ipod-nano\") {\n id\n handle\n title\n productType\n description\n vendor\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\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 productByHandle(handle: \"ipod-nano\") {\n id\n handle\n title\n productType\n description\n vendor\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\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 productByHandle(handle: \"ipod-nano\") {\n id\n handle\n title\n productType\n description\n vendor\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\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 productByHandle(handle: \"ipod-nano\") {\n id\n handle\n title\n productType\n description\n vendor\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n productByHandle(handle: \"ipod-nano\") {\n id\n handle\n title\n productType\n description\n vendor\n priceRangeV2 {\n minVariantPrice {\n amount\n currencyCode\n }\n maxVariantPrice {\n amount\n currencyCode\n }\n }\n }\n}"
input: null
response: { "data": { "productByHandle": { "id": "gid://shopify/Product/440089423", "handle": "ipod-nano", "title": "IPod Nano - 8GB", "productType": "Cult Products", "description": "It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.", "vendor": "Apple", "priceRangeV2": { "minVariantPrice": { "amount": "199.0", "currencyCode": "USD" }, "maxVariantPrice": { "amount": "199.0", "currencyCode": "USD" } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-07/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query getProductIdFromHandle($handle: String!) { productByHandle(handle: $handle) { id } }\",\n \"variables\": {\n \"handle\": \"element\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query getProductIdFromHandle($handle: String!) {\n productByHandle(handle: $handle) {\n id\n }\n }`,\n \"variables\": {\n \"handle\": \"element\"\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 getProductIdFromHandle($handle: String!) {\n productByHandle(handle: $handle) {\n id\n }\n }\nQUERY\n\nvariables = {\n \"handle\": \"element\"\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 getProductIdFromHandle($handle: String!) {\n productByHandle(handle: $handle) {\n id\n }\n }\nQUERY;\n\n$variables = [\n \"handle\" => \"element\",\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 getProductIdFromHandle($handle: String!) {\n productByHandle(handle: $handle) {\n id\n }\n }`,\n {\n variables: {\n \"handle\": \"element\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query getProductIdFromHandle($handle: String!) {\n productByHandle(handle: $handle) {\n id\n }\n}"
input: { "handle": "element" }
response: { "data": { "productByHandle": { "id": "gid://shopify/Product/20995642" } } }