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 { discountNode(id: \\\"gid://shopify/DiscountAutomaticNode/299501151\\\") { id discount { ... on DiscountCodeBasic { title } ... on DiscountCodeBxgy { title } ... on DiscountCodeFreeShipping { title } ... on DiscountAutomaticApp { title } ... on DiscountAutomaticBasic { title } ... on DiscountAutomaticBxgy { title } ... on DiscountAutomaticFreeShipping { title } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n discountNode(id: \"gid://shopify/DiscountAutomaticNode/299501151\") {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n }\n ... on DiscountCodeBxgy {\n title\n }\n ... on DiscountCodeFreeShipping {\n title\n }\n ... on DiscountAutomaticApp {\n title\n }\n ... on DiscountAutomaticBasic {\n title\n }\n ... on DiscountAutomaticBxgy {\n title\n }\n ... on DiscountAutomaticFreeShipping {\n title\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 discountNode(id: \"gid://shopify/DiscountAutomaticNode/299501151\") {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n }\n ... on DiscountCodeBxgy {\n title\n }\n ... on DiscountCodeFreeShipping {\n title\n }\n ... on DiscountAutomaticApp {\n title\n }\n ... on DiscountAutomaticBasic {\n title\n }\n ... on DiscountAutomaticBxgy {\n title\n }\n ... on DiscountAutomaticFreeShipping {\n title\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 discountNode(id: \"gid://shopify/DiscountAutomaticNode/299501151\") {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n }\n ... on DiscountCodeBxgy {\n title\n }\n ... on DiscountCodeFreeShipping {\n title\n }\n ... on DiscountAutomaticApp {\n title\n }\n ... on DiscountAutomaticBasic {\n title\n }\n ... on DiscountAutomaticBxgy {\n title\n }\n ... on DiscountAutomaticFreeShipping {\n title\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 discountNode(id: \"gid://shopify/DiscountAutomaticNode/299501151\") {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n }\n ... on DiscountCodeBxgy {\n title\n }\n ... on DiscountCodeFreeShipping {\n title\n }\n ... on DiscountAutomaticApp {\n title\n }\n ... on DiscountAutomaticBasic {\n title\n }\n ... on DiscountAutomaticBxgy {\n title\n }\n ... on DiscountAutomaticFreeShipping {\n title\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n discountNode(id: \"gid://shopify/DiscountAutomaticNode/299501151\") {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n }\n ... on DiscountCodeBxgy {\n title\n }\n ... on DiscountCodeFreeShipping {\n title\n }\n ... on DiscountAutomaticApp {\n title\n }\n ... on DiscountAutomaticBasic {\n title\n }\n ... on DiscountAutomaticBxgy {\n title\n }\n ... on DiscountAutomaticFreeShipping {\n title\n }\n }\n }\n}"
input: null
response: { "data": { "discountNode": { "id": "gid://shopify/DiscountAutomaticNode/299501151", "discount": { "title": "My automatic discount" } } } }
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 DiscountShow($id: ID!) { discountNode(id: $id) { id discount { ... on DiscountCodeBasic { title summary status codes(first: 1) { nodes { code } } } ... on DiscountAutomaticBasic { title summary status } ... on DiscountCodeBxgy { title summary status codes(first: 1) { nodes { code } } } ... on DiscountAutomaticBxgy { title summary status } ... on DiscountCodeFreeShipping { title summary status codes(first: 1) { nodes { code } } } ... on DiscountCodeApp { title status appDiscountType { title } codes(first: 1) { nodes { code } } } ... on DiscountAutomaticApp { title status appDiscountType { title } } } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountNode/299501151\"\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DiscountShow($id: ID!) {\n discountNode(id: $id) {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBasic {\n title\n summary\n status\n }\n ... on DiscountCodeBxgy {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n status\n }\n ... on DiscountCodeFreeShipping {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountCodeApp {\n title\n status\n appDiscountType {\n title\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n title\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountNode/299501151\"\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 DiscountShow($id: ID!) {\n discountNode(id: $id) {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBasic {\n title\n summary\n status\n }\n ... on DiscountCodeBxgy {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n status\n }\n ... on DiscountCodeFreeShipping {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountCodeApp {\n title\n status\n appDiscountType {\n title\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n title\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountNode/299501151\"\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 DiscountShow($id: ID!) {\n discountNode(id: $id) {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBasic {\n title\n summary\n status\n }\n ... on DiscountCodeBxgy {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n status\n }\n ... on DiscountCodeFreeShipping {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountCodeApp {\n title\n status\n appDiscountType {\n title\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n title\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DiscountNode/299501151\",\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 DiscountShow($id: ID!) {\n discountNode(id: $id) {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBasic {\n title\n summary\n status\n }\n ... on DiscountCodeBxgy {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n status\n }\n ... on DiscountCodeFreeShipping {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountCodeApp {\n title\n status\n appDiscountType {\n title\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n title\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountNode/299501151\"\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DiscountShow($id: ID!) {\n discountNode(id: $id) {\n id\n discount {\n ... on DiscountCodeBasic {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBasic {\n title\n summary\n status\n }\n ... on DiscountCodeBxgy {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n status\n }\n ... on DiscountCodeFreeShipping {\n title\n summary\n status\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountCodeApp {\n title\n status\n appDiscountType {\n title\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n title\n }\n }\n }\n }\n}"
input: { "id": "gid://shopify/DiscountNode/299501151" }
response: { "data": { "discountNode": { "id": "gid://shopify/DiscountAutomaticNode/299501151", "discount": { "title": "My automatic discount", "summary": "$100.00 off entire order • Minimum quantity of 1", "status": "SCHEDULED" } } } }