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 { discountNodes(first: 3) { edges { node { 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 discountNodes(first: 3) {\n edges {\n node {\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 }`,\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 discountNodes(first: 3) {\n edges {\n node {\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 }\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 discountNodes(first: 3) {\n edges {\n node {\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 }\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 discountNodes(first: 3) {\n edges {\n node {\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 }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n discountNodes(first: 3) {\n edges {\n node {\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}"
input: null
response: { "data": { "discountNodes": { "edges": [ { "node": { "id": "gid://shopify/DiscountAutomaticNode/52422887", "discount": { "title": "Percentage off (by Automatic App Discount)" } } }, { "node": { "id": "gid://shopify/DiscountAutomaticNode/198286294", "discount": { "title": "My automatic bogo" } } }, { "node": { "id": "gid://shopify/DiscountAutomaticNode/299501151", "discount": { "title": "My automatic discount" } } } ] } } }
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 DiscountList($first: Int) { discountNodes(first: $first) { edges { node { id __typename 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 { functionId } codes(first: 1) { nodes { code } } } ... on DiscountAutomaticApp { title status appDiscountType { functionId } } } } } } }\",\n \"variables\": {\n \"first\": 5\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `query DiscountList($first: Int) {\n discountNodes(first: $first) {\n edges {\n node {\n id\n __typename\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 functionId\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n functionId\n }\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"first\": 5\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 DiscountList($first: Int) {\n discountNodes(first: $first) {\n edges {\n node {\n id\n __typename\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 functionId\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n functionId\n }\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"first\": 5\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 DiscountList($first: Int) {\n discountNodes(first: $first) {\n edges {\n node {\n id\n __typename\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 functionId\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n functionId\n }\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"first\" => 5,\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 DiscountList($first: Int) {\n discountNodes(first: $first) {\n edges {\n node {\n id\n __typename\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 functionId\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n functionId\n }\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"first\": 5\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "query DiscountList($first: Int) {\n discountNodes(first: $first) {\n edges {\n node {\n id\n __typename\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 functionId\n }\n codes(first: 1) {\n nodes {\n code\n }\n }\n }\n ... on DiscountAutomaticApp {\n title\n status\n appDiscountType {\n functionId\n }\n }\n }\n }\n }\n }\n}"
input: { "first": 5 }
response: { "data": { "discountNodes": { "edges": [ { "node": { "id": "gid://shopify/DiscountCodeNode/2429471", "__typename": "DiscountNode", "discount": { "title": "cart_amount", "summary": "$10.00 off one-time purchase products", "status": "ACTIVE", "codes": { "nodes": [] } } } }, { "node": { "id": "gid://shopify/DiscountAutomaticNode/52422887", "__typename": "DiscountNode", "discount": { "title": "Percentage off (by Automatic App Discount)", "status": "EXPIRED", "appDiscountType": { "functionId": "5d3cc7e3-8348-4ede-8a40-6b83133c773c" } } } }, { "node": { "id": "gid://shopify/DiscountAutomaticNode/198286294", "__typename": "DiscountNode", "discount": { "title": "My automatic bogo", "summary": "Buy 1 item, get 1 item free", "status": "SCHEDULED" } } }, { "node": { "id": "gid://shopify/DiscountAutomaticNode/299501151", "__typename": "DiscountNode", "discount": { "title": "My automatic discount", "summary": "$100.00 off entire order • Minimum quantity of 1", "status": "SCHEDULED" } } }, { "node": { "id": "gid://shopify/DiscountCodeNode/299564956", "__typename": "DiscountNode", "discount": { "title": "product_bogo", "summary": "Buy 1 item, get 1 item free", "status": "ACTIVE", "codes": { "nodes": [] } } } } ] } } }