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 { codeDiscountNode(id: \\\"gid://shopify/DiscountCodeNode/206265824\\\") { id codeDiscount { ... on DiscountCodeBasic { title summary } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\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 codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\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 codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\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 codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n }\n }\n }\n}"
input: null
response: { "data": { "codeDiscountNode": { "id": "gid://shopify/DiscountCodeNode/206265824", "codeDiscount": { "title": "percentage_off_code", "summary": "10% off one-time purchase products" } } } }
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 DiscountRedeemCodeList($discountId: ID!) { codeDiscountNode(id: $discountId) { codeDiscount { ... on DiscountCodeBasic { title codes(first: 10) { nodes { id code } } } ... on DiscountCodeBxgy { title codes(first: 10) { nodes { id code } } } ... on DiscountCodeFreeShipping { title codes(first: 10) { nodes { id code } } } } } }\",\n \"variables\": {\n \"discountId\": \"gid://shopify/DiscountCodeNode/206265824\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DiscountRedeemCodeList($discountId: ID!) {\n codeDiscountNode(id: $discountId) {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeFreeShipping {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"discountId\": \"gid://shopify/DiscountCodeNode/206265824\"\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 DiscountRedeemCodeList($discountId: ID!) {\n codeDiscountNode(id: $discountId) {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeFreeShipping {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"discountId\": \"gid://shopify/DiscountCodeNode/206265824\"\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 DiscountRedeemCodeList($discountId: ID!) {\n codeDiscountNode(id: $discountId) {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeFreeShipping {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"discountId\" => \"gid://shopify/DiscountCodeNode/206265824\",\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 DiscountRedeemCodeList($discountId: ID!) {\n codeDiscountNode(id: $discountId) {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeFreeShipping {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"discountId\": \"gid://shopify/DiscountCodeNode/206265824\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DiscountRedeemCodeList($discountId: ID!) {\n codeDiscountNode(id: $discountId) {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeBxgy {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n ... on DiscountCodeFreeShipping {\n title\n codes(first: 10) {\n nodes {\n id\n code\n }\n }\n }\n }\n }\n}"
input: { "discountId": "gid://shopify/DiscountCodeNode/206265824" }
response: { "data": { "codeDiscountNode": { "codeDiscount": { "title": "percentage_off_code", "codes": { "nodes": [ { "id": "gid://shopify/DiscountRedeemCode/241951653", "code": "percentage_off_code" } ] } } } } }
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 DiscountCodeShow { codeDiscountNode(id: \\\"gid://shopify/DiscountCodeNode/206265824\\\") { id codeDiscount { ... on DiscountCodeBasic { title summary codes(first: 10) { nodes { code id } } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query DiscountCodeShow {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n codes(first: 10) {\n nodes {\n code\n id\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 DiscountCodeShow {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n codes(first: 10) {\n nodes {\n code\n id\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\n query DiscountCodeShow {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n codes(first: 10) {\n nodes {\n code\n id\n }\n }\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 DiscountCodeShow {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n codes(first: 10) {\n nodes {\n code\n id\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query DiscountCodeShow {\n codeDiscountNode(id: \"gid://shopify/DiscountCodeNode/206265824\") {\n id\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n summary\n codes(first: 10) {\n nodes {\n code\n id\n }\n }\n }\n }\n }\n}"
input: null
response: { "data": { "codeDiscountNode": { "id": "gid://shopify/DiscountCodeNode/206265824", "codeDiscount": { "title": "percentage_off_code", "summary": "10% off one-time purchase products", "codes": { "nodes": [ { "code": "percentage_off_code", "id": "gid://shopify/DiscountRedeemCode/241951653" } ] } } } } }