Discussing APIs and development related to customers, discounts, and order management.
When running a bulk query on my test shop to get the buy X get Y item discounts, there seems to be no way for me to tell if the items that get returned belong to the customerGets property or customerBuys property. Am I missing an identifier in my GraphQL query to make this connection from __parentId to the correct field in the parent?
The "Dawn", "The Compare at Price Snowboard" and "The 3p Fulfilled Snowboard" products links to the automatic discount above it, but from the results, it is not possible to tell to which of the "customerGets", or "customerBuys" properties the items belong to individually.
Screenshot of the setup in the admin page
The query
query AutomaticDiscountNodesQuery {
automaticDiscountNodes {
edges {
cursor
node {
id
automaticDiscount {
... on DiscountAutomaticBxgy {
customerBuys {
items {
... on DiscountProducts {
...DiscountProductsFragment
__typename
}
__typename
}
__typename
}
customerGets {
items {
... on DiscountProducts {
...DiscountProductsFragment
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
}
fragment DiscountProductsFragment on DiscountProducts {
products {
edges {
cursor
node {
id
title
options {
id
__typename
}
__typename
}
__typename
}
__typename
}
productVariants {
edges {
cursor
node {
id
title
price
product {
id
__typename
}
__typename
}
__typename
}
__typename
}
__typename
}
The result
{"id":"gid:\/\/shopify\/DiscountAutomaticNode\/1405340320039","automaticDiscount":{"customerBuys":{"items":{"__typename":"DiscountProducts"},"__typename":"DiscountCustomerBuys"},"customerGets":{"items":{"__typename":"DiscountProducts"},"__typename":"DiscountCustomerGets"},"__typename":"DiscountAutomaticBxgy"},"__typename":"DiscountAutomaticNode"}
{"id":"gid:\/\/shopify\/ProductVariant\/46273146847527","title":"Dawn","price":"699.95","product":{"id":"gid:\/\/shopify\/Product\/8564261159207","__typename":"Product"},"__typename":"ProductVariant","__parentId":"gid:\/\/shopify\/DiscountAutomaticNode\/1405340320039"}
{"id":"gid:\/\/shopify\/Product\/8564261224743","title":"The Compare at Price Snowboard","options":[{"id":"gid:\/\/shopify\/ProductOption\/10836559659303","__typename":"ProductOption"}],"__typename":"Product","__parentId":"gid:\/\/shopify\/DiscountAutomaticNode\/1405340320039"}
{"id":"gid:\/\/shopify\/Product\/8564261323047","title":"The 3p Fulfilled Snowboard","options":[{"id":"gid:\/\/shopify\/ProductOption\/10836559757607","__typename":"ProductOption"}],"__typename":"Product","__parentId":"gid:\/\/shopify\/DiscountAutomaticNode\/1405340320039"}
{"id":"gid:\/\/shopify\/DiscountAutomaticNode\/1405340352807","automaticDiscount":{"__typename":"DiscountAutomaticBasic"},"__typename":"DiscountAutomaticNode"}
{"id":"gid:\/\/shopify\/DiscountAutomaticNode\/1406261133607","automaticDiscount":{"__typename":"DiscountAutomaticBasic"},"__typename":"DiscountAutomaticNode"}
{"id":"gid:\/\/shopify\/DiscountAutomaticNode\/1406878089511","automaticDiscount":{"__typename":"DiscountAutomaticBasic"},"__typename":"DiscountAutomaticNode"}