Version: 2024-04
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-04/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"query { automaticDiscountNodes(first: 2) { edges { node { id automaticDiscount { ... on DiscountAutomaticBasic { title summary customerGets { items { ... on AllDiscountItems { allItems } } } minimumRequirement { ... on DiscountMinimumQuantity { greaterThanOrEqualToQuantity } } } ... on DiscountAutomaticBxgy { title summary customerBuys { value { ... on DiscountQuantity { quantity } ... on DiscountPurchaseAmount { amount } } } customerGets { value { ... on DiscountOnQuantity { quantity { quantity } } } } } } } } } }\"\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: `query {\n automaticDiscountNodes(first: 2) {\n edges {\n node {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n title\n summary\n customerGets {\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n ... on DiscountPurchaseAmount {\n amount\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n quantity {\n quantity\n }\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 automaticDiscountNodes(first: 2) {\n edges {\n node {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n title\n summary\n customerGets {\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n ... on DiscountPurchaseAmount {\n amount\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n quantity {\n quantity\n }\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 automaticDiscountNodes(first: 2) {\n edges {\n node {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n title\n summary\n customerGets {\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n ... on DiscountPurchaseAmount {\n amount\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n quantity {\n quantity\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }`,\n);\n\nconst data = await response.json();\n" Graphql query: "query {\n automaticDiscountNodes(first: 2) {\n edges {\n node {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n title\n summary\n customerGets {\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n minimumRequirement {\n ... on DiscountMinimumQuantity {\n greaterThanOrEqualToQuantity\n }\n }\n }\n ... on DiscountAutomaticBxgy {\n title\n summary\n customerBuys {\n value {\n ... on DiscountQuantity {\n quantity\n }\n ... on DiscountPurchaseAmount {\n amount\n }\n }\n }\n customerGets {\n value {\n ... on DiscountOnQuantity {\n quantity {\n quantity\n }\n }\n }\n }\n }\n }\n }\n }\n }\n}"
input: null
response: { "data": { "automaticDiscountNodes": { "edges": [ { "node": { "id": "gid://shopify/DiscountAutomaticNode/198286294", "automaticDiscount": { "title": "My automatic bogo", "summary": "Buy 1 item, get 1 item free", "customerBuys": { "value": { "quantity": "1" } }, "customerGets": { "value": { "quantity": { "quantity": "1" } } } } } }, { "node": { "id": "gid://shopify/DiscountAutomaticNode/299501151", "automaticDiscount": { "title": "My automatic discount", "summary": "$100.00 off entire order • Minimum quantity of 1", "customerGets": { "items": { "allItems": true } }, "minimumRequirement": { "greaterThanOrEqualToQuantity": "1" } } } } ] } } }