ProductPromotion
Describes a product promotion, providing details such as the promotion type, title, and description.
Type Definition
type ProductPromotion {
type: String
title: String
description: String
}Fields
| Field | Type | Nullable | Description | Relationship |
|---|---|---|---|---|
type | String | Yes | Returns the promotion type. | None |
title | String | Yes | Returns the promotion title if any. | None |
description | String | Yes | Returns the promotion description if any. | None |
Relationships
- The
ProductPromotiontype is used by theProductVariantobject through itspromotionfield. This indicates that each product variant can have an associated promotion described by this type.
Usage Examples
Basic Query
{
productVariant(id: 12345) {
promotion {
type
title
description
}
}
}Field Selection
{
productVariant(id: 12345) {
promotion {
title
description
}
}
}Nested Queries
{
productVariant(id: 12345) {
id
sku
promotion {
type
title
}
}
}Filtering and Sorting
The ProductPromotion object itself does not support filtering or sorting directly. Filtering and sorting should be applied on the parent objects such as ProductVariant when querying promotions.
Example: Filtering product variants that have a promotion with a specific type.
{
productVariants(filter: { promotionType: "Discount" }, sort: { field: "sku", direction: ASC }) {
edges {
node {
id
sku
promotion {
type
title
}
}
}
}
}Note: The above filtering example assumes the API supports filtering on promotionType at the ProductVariant level.
Implements
The ProductPromotion type does not implement any interfaces.
Connections
There are no direct connection fields on ProductPromotion. It is embedded within ProductVariant.
Related Types
- ProductVariant: The parent object that contains the
promotionfield of typeProductPromotion.
Best Practices
- Always check for nullability on all fields (
type,title,description) as they are optional and may not be present in every promotion. - Use field selection to request only the promotion details you need to optimize query performance.
- When querying promotions, consider filtering and sorting at the
ProductVariantlevel to efficiently retrieve relevant promotions. - Avoid requesting unnecessary nested data to reduce response size and improve API responsiveness.
Notes
- The
ProductPromotionobject contains only scalar fields and no computed or derived fields. - There are no field arguments on
ProductPromotion. - Since
ProductPromotionis a nested object withinProductVariant, accessing it requires querying the parentProductVariant. - The API currently requires no authentication; however, this may change in future versions.
- Consider caching promotion data on the client side if promotions do not change frequently to reduce API calls.
- Handle cases where promotion fields may be null gracefully in your application to avoid runtime errors.
Last updated on