Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add `translatable_content` to translation types. (#15652)

Piotr Zabieglik779934f3c346
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6905499609..4ce1ddd81e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,7 @@ All notable, unreleased changes to this project will be documented in this file.
### Breaking changes
### GraphQL API
+- Add `translatableContent` to all translation types; add translated object id to all translatable content types - #15617 by @zedzior
- Add a `taxConfiguration` to a `Channel` - #15610 by @Air-t
diff --git a/saleor/graphql/schema.graphql b/saleor/graphql/schema.graphql
index d5c1b8ce2e..800908aa58 100644
--- a/saleor/graphql/schema.graphql
+++ b/saleor/graphql/schema.graphql
@@ -4204,6 +4204,13 @@ type ShippingMethodTranslation implements Node @doc(category: "Shipping") {
Rich text format. For reference see https://editorjs.io/
"""
description: JSONString
+
+ """
+ Represents the shipping method fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: ShippingMethodTranslatableContent
}
type LanguageDisplay {
@@ -4997,6 +5004,44 @@ enum LanguageCodeEnum {
ZU_ZA
}
+"""
+Represents shipping method's original translatable fields and related translations.
+"""
+type ShippingMethodTranslatableContent implements Node @doc(category: "Shipping") {
+ """The ID of the shipping method translatable content."""
+ id: ID!
+
+ """
+ The ID of the shipping method to translate.
+
+ Added in Saleor 3.14.
+ """
+ shippingMethodId: ID!
+
+ """Shipping method name to translate."""
+ name: String!
+
+ """
+ Shipping method description to translate.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ description: JSONString
+
+ """Returns translated shipping method fields for the given language code."""
+ translation(
+ """A language code to return the translation for shipping method."""
+ languageCode: LanguageCodeEnum!
+ ): ShippingMethodTranslation
+
+ """
+ Shipping method are the methods you'll use to get customer's orders to them. They are directly exposed to the customers.
+
+ Requires one of the following permissions: MANAGE_SHIPPING.
+ """
+ shippingMethod: ShippingMethodType @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
+}
+
"""Represents shipping method channel listing."""
type ShippingMethodChannelListing implements Node @doc(category: "Shipping") {
"""The ID of shipping method channel listing."""
@@ -6643,6 +6688,103 @@ type AttributeValueTranslation implements Node @doc(category: "Attributes") {
"""Translated plain text attribute value ."""
plainText: String
+
+ """
+ Represents the attribute value fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: AttributeValueTranslatableContent
+}
+
+"""
+Represents attribute value's original translatable fields and related translations.
+"""
+type AttributeValueTranslatableContent implements Node @doc(category: "Attributes") {
+ """The ID of the attribute value translatable content."""
+ id: ID!
+
+ """
+ The ID of the attribute value to translate.
+
+ Added in Saleor 3.14.
+ """
+ attributeValueId: ID!
+
+ """Name of the attribute value to translate."""
+ name: String!
+
+ """
+ Attribute value.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ richText: JSONString
+
+ """Attribute plain text value."""
+ plainText: String
+
+ """Returns translated attribute value fields for the given language code."""
+ translation(
+ """A language code to return the translation for attribute value."""
+ languageCode: LanguageCodeEnum!
+ ): AttributeValueTranslation
+
+ """Represents a value of an attribute."""
+ attributeValue: AttributeValue @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
+
+ """
+ Associated attribute that can be translated.
+
+ Added in Saleor 3.9.
+ """
+ attribute: AttributeTranslatableContent
+}
+
+"""
+Represents attribute's original translatable fields and related translations.
+"""
+type AttributeTranslatableContent implements Node @doc(category: "Attributes") {
+ """The ID of the attribute translatable content."""
+ id: ID!
+
+ """
+ The ID of the attribute to translate.
+
+ Added in Saleor 3.14.
+ """
+ attributeId: ID!
+
+ """Name of the attribute to translate."""
+ name: String!
+
+ """Returns translated attribute fields for the given language code."""
+ translation(
+ """A language code to return the translation for attribute."""
+ languageCode: LanguageCodeEnum!
+ ): AttributeTranslation
+
+ """Custom attribute of a product."""
+ attribute: Attribute @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
+}
+
+"""Represents attribute translations."""
+type AttributeTranslation implements Node @doc(category: "Attributes") {
+ """The ID of the attribute translation."""
+ id: ID!
+
+ """Translation language."""
+ language: LanguageDisplay!
+
+ """Translated attribute name."""
+ name: String!
+
+ """
+ Represents the attribute fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: AttributeTranslatableContent
}
type File {
@@ -6682,18 +6824,6 @@ input AttributeValueFilterInput @doc(category: "Attributes") {
slugs: [String!]
}
-"""Represents attribute translations."""
-type AttributeTranslation implements Node @doc(category: "Attributes") {
- """The ID of the attribute translation."""
- id: ID!
-
- """Translation language."""
- language: LanguageDisplay!
-
- """Translated attribute name."""
- name: String!
-}
-
type ProductTypeCountableConnection @doc(category: "Products") {
"""Pagination data for this connection."""
pageInfo: PageInfo!
@@ -7468,6 +7598,60 @@ type CategoryTranslation implements Node @doc(category: "Products") {
Rich text format. For reference see https://editorjs.io/
"""
descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+
+ """
+ Represents the category fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: CategoryTranslatableContent
+}
+
+"""
+Represents category original translatable fields and related translations.
+"""
+type CategoryTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the category translatable content."""
+ id: ID!
+
+ """
+ The ID of the category to translate.
+
+ Added in Saleor 3.14.
+ """
+ categoryId: ID!
+
+ """SEO title to translate."""
+ seoTitle: String
+
+ """SEO description to translate."""
+ seoDescription: String
+
+ """Name of the category translatable content."""
+ name: String!
+
+ """
+ Category description to translate.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ description: JSONString
+
+ """
+ Description of the category.
+
+ Rich text format. For reference see https://editorjs.io/
+ """
+ descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+
+ """Returns translated category fields for the given language code."""
+ translation(
+ """A language code to return the translation for category."""
+ languageCode: LanguageCodeEnum!
+ ): CategoryTranslation
+
+ """Represents a single category of products."""
+ category: Category @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
}
"""Represents a version of a product such as different size or color."""
@@ -7929,6 +8113,43 @@ type ProductVariantTranslation implements Node @doc(category: "Products") {
"""Translated product variant name."""
name: String!
+
+ """
+ Represents the product variant fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: ProductVariantTranslatableContent
+}
+
+"""
+Represents product variant's original translatable fields and related translations.
+"""
+type ProductVariantTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the product variant translatable content."""
+ id: ID!
+
+ """
+ The ID of the product variant to translate.
+
+ Added in Saleor 3.14.
+ """
+ productVariantId: ID!
+
+ """Name of the product variant to translate."""
+ name: String!
+
+ """Returns translated product variant fields for the given language code."""
+ translation(
+ """A language code to return the translation for product variant."""
+ languageCode: LanguageCodeEnum!
+ ): ProductVariantTranslation
+
+ """Represents a version of a product such as different size or color."""
+ productVariant: ProductVariant @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
+
+ """List of product variant attribute values that can be translated."""
+ attributeValues: [AttributeValueTranslatableContent!]!
}
"""Represents digital content associated with a product variant."""
@@ -8363,225 +8584,134 @@ type CollectionTranslation implements Node @doc(category: "Products") {
Rich text format. For reference see https://editorjs.io/
"""
descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+
+ """
+ Represents the collection fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: CollectionTranslatableContent
}
-"""Represents collection channel listing."""
-type CollectionChannelListing implements Node @doc(category: "Products") {
- """The ID of the collection channel listing."""
+"""
+Represents collection's original translatable fields and related translations.
+"""
+type CollectionTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the collection translatable content."""
id: ID!
- publicationDate: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `publishedAt` field to fetch the publication date.")
"""
- The collection publication date.
+ The ID of the collection to translate.
- Added in Saleor 3.3.
+ Added in Saleor 3.14.
"""
- publishedAt: DateTime
-
- """Indicates if the collection is published in the channel."""
- isPublished: Boolean!
+ collectionId: ID!
- """The channel to which the collection belongs."""
- channel: Channel!
-}
+ """SEO title to translate."""
+ seoTitle: String
-"""Represents product translations."""
-type ProductTranslation implements Node @doc(category: "Products") {
- """The ID of the product translation."""
- id: ID!
+ """SEO description to translate."""
+ seoDescription: String
- """Translation language."""
- language: LanguageDisplay!
-
- """Translated SEO title."""
- seoTitle: String
-
- """Translated SEO description."""
- seoDescription: String
-
- """Translated product name."""
- name: String
+ """Collection's name to translate."""
+ name: String!
"""
- Translated description of the product.
+ Collection's description to translate.
Rich text format. For reference see https://editorjs.io/
"""
description: JSONString
"""
- Translated description of the product.
+ Description of the collection.
Rich text format. For reference see https://editorjs.io/
"""
descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
-}
-
-type WarehouseCountableConnection @doc(category: "Products") {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [WarehouseCountableEdge!]!
-
- """A total count of items in the collection."""
- totalCount: Int
-}
-
-type WarehouseCountableEdge @doc(category: "Products") {
- """The item at the end of the edge."""
- node: Warehouse!
-
- """A cursor for use in pagination."""
- cursor: String!
-}
-
-input WarehouseFilterInput @doc(category: "Products") {
- clickAndCollectOption: WarehouseClickAndCollectOptionEnum
- metadata: [MetadataFilter!]
- search: String
- ids: [ID!]
- isPrivate: Boolean
- channels: [ID!]
- slugs: [String!]
-}
-
-input WarehouseSortingInput @doc(category: "Products") {
- """Specifies the direction in which to sort warehouses."""
- direction: OrderDirection!
- """Sort warehouses by the selected field."""
- field: WarehouseSortField!
-}
+ """Returns translated collection fields for the given language code."""
+ translation(
+ """A language code to return the translation for collection."""
+ languageCode: LanguageCodeEnum!
+ ): CollectionTranslation
-enum WarehouseSortField @doc(category: "Products") {
- """Sort warehouses by name."""
- NAME
+ """Represents a collection of products."""
+ collection: Collection @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
}
-type TranslatableItemConnection {
- """Pagination data for this connection."""
- pageInfo: PageInfo!
- edges: [TranslatableItemEdge!]!
+"""Represents collection channel listing."""
+type CollectionChannelListing implements Node @doc(category: "Products") {
+ """The ID of the collection channel listing."""
+ id: ID!
+ publicationDate: Date @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `publishedAt` field to fetch the publication date.")
- """A total count of items in the collection."""
- totalCount: Int
-}
+ """
+ The collection publication date.
+
+ Added in Saleor 3.3.
+ """
+ publishedAt: DateTime
-type TranslatableItemEdge {
- """The item at the end of the edge."""
- node: TranslatableItem!
+ """Indicates if the collection is published in the channel."""
+ isPublished: Boolean!
- """A cursor for use in pagination."""
- cursor: String!
+ """The channel to which the collection belongs."""
+ channel: Channel!
}
-union TranslatableItem = ProductTranslatableContent | CollectionTranslatableContent | CategoryTranslatableContent | AttributeTranslatableContent | AttributeValueTranslatableContent | ProductVariantTranslatableContent | PageTranslatableContent | ShippingMethodTranslatableContent | VoucherTranslatableContent | MenuItemTranslatableContent | PromotionTranslatableContent | PromotionRuleTranslatableContent | SaleTranslatableContent
-
-"""
-Represents product's original translatable fields and related translations.
-"""
-type ProductTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the product translatable content."""
+"""Represents product translations."""
+type ProductTranslation implements Node @doc(category: "Products") {
+ """The ID of the product translation."""
id: ID!
- """SEO title to translate."""
+ """Translation language."""
+ language: LanguageDisplay!
+
+ """Translated SEO title."""
seoTitle: String
- """SEO description to translate."""
+ """Translated SEO description."""
seoDescription: String
- """Product's name to translate."""
- name: String!
+ """Translated product name."""
+ name: String
"""
- Product's description to translate.
+ Translated description of the product.
Rich text format. For reference see https://editorjs.io/
"""
description: JSONString
"""
- Description of the product.
+ Translated description of the product.
Rich text format. For reference see https://editorjs.io/
"""
descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
- """Returns translated product fields for the given language code."""
- translation(
- """A language code to return the translation for product."""
- languageCode: LanguageCodeEnum!
- ): ProductTranslation
-
- """Represents an individual item for sale in the storefront."""
- product: Product @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
-
- """List of product attribute values that can be translated."""
- attributeValues: [AttributeValueTranslatableContent!]!
-}
-
-"""
-Represents attribute value's original translatable fields and related translations.
-"""
-type AttributeValueTranslatableContent implements Node @doc(category: "Attributes") {
- """The ID of the attribute value translatable content."""
- id: ID!
-
- """Name of the attribute value to translate."""
- name: String!
-
"""
- Attribute value.
+ Represents the product fields to translate.
- Rich text format. For reference see https://editorjs.io/
- """
- richText: JSONString
-
- """Attribute plain text value."""
- plainText: String
-
- """Returns translated attribute value fields for the given language code."""
- translation(
- """A language code to return the translation for attribute value."""
- languageCode: LanguageCodeEnum!
- ): AttributeValueTranslation
-
- """Represents a value of an attribute."""
- attributeValue: AttributeValue @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
-
- """
- Associated attribute that can be translated.
-
- Added in Saleor 3.9.
+ Added in Saleor 3.14.
"""
- attribute: AttributeTranslatableContent
+ translatableContent: ProductTranslatableContent
}
"""
-Represents attribute's original translatable fields and related translations.
+Represents product's original translatable fields and related translations.
"""
-type AttributeTranslatableContent implements Node @doc(category: "Attributes") {
- """The ID of the attribute."""
+type ProductTranslatableContent implements Node @doc(category: "Products") {
+ """The ID of the product translatable content."""
id: ID!
- """Name of the attribute to translate."""
- name: String!
-
- """Returns translated attribute fields for the given language code."""
- translation(
- """A language code to return the translation for attribute."""
- languageCode: LanguageCodeEnum!
- ): AttributeTranslation
-
- """Custom attribute of a product."""
- attribute: Attribute @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
-}
-
-"""
-Represents collection's original translatable fields and related translations.
-"""
-type CollectionTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the collection translatable content."""
- id: ID!
+ """
+ The ID of the product to translate.
+
+ Added in Saleor 3.14.
+ """
+ productId: ID!
"""SEO title to translate."""
seoTitle: String
@@ -8589,96 +8719,95 @@ type CollectionTranslatableContent implements Node @doc(category: "Products") {
"""SEO description to translate."""
seoDescription: String
- """Collection's name to translate."""
+ """Product's name to translate."""
name: String!
"""
- Collection's description to translate.
+ Product's description to translate.
Rich text format. For reference see https://editorjs.io/
"""
description: JSONString
"""
- Description of the collection.
+ Description of the product.
Rich text format. For reference see https://editorjs.io/
"""
descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
- """Returns translated collection fields for the given language code."""
+ """Returns translated product fields for the given language code."""
translation(
- """A language code to return the translation for collection."""
+ """A language code to return the translation for product."""
languageCode: LanguageCodeEnum!
- ): CollectionTranslation
+ ): ProductTranslation
- """Represents a collection of products."""
- collection: Collection @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
-}
+ """Represents an individual item for sale in the storefront."""
+ product: Product @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
-"""
-Represents category original translatable fields and related translations.
-"""
-type CategoryTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the category translatable content."""
- id: ID!
+ """List of product attribute values that can be translated."""
+ attributeValues: [AttributeValueTranslatableContent!]!
+}
- """SEO title to translate."""
- seoTitle: String
+type WarehouseCountableConnection @doc(category: "Products") {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [WarehouseCountableEdge!]!
- """SEO description to translate."""
- seoDescription: String
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """Name of the category translatable content."""
- name: String!
+type WarehouseCountableEdge @doc(category: "Products") {
+ """The item at the end of the edge."""
+ node: Warehouse!
- """
- Category description to translate.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
+ """A cursor for use in pagination."""
+ cursor: String!
+}
- """
- Description of the category.
-
- Rich text format. For reference see https://editorjs.io/
- """
- descriptionJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `description` field instead.")
+input WarehouseFilterInput @doc(category: "Products") {
+ clickAndCollectOption: WarehouseClickAndCollectOptionEnum
+ metadata: [MetadataFilter!]
+ search: String
+ ids: [ID!]
+ isPrivate: Boolean
+ channels: [ID!]
+ slugs: [String!]
+}
- """Returns translated category fields for the given language code."""
- translation(
- """A language code to return the translation for category."""
- languageCode: LanguageCodeEnum!
- ): CategoryTranslation
+input WarehouseSortingInput @doc(category: "Products") {
+ """Specifies the direction in which to sort warehouses."""
+ direction: OrderDirection!
- """Represents a single category of products."""
- category: Category @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
+ """Sort warehouses by the selected field."""
+ field: WarehouseSortField!
}
-"""
-Represents product variant's original translatable fields and related translations.
-"""
-type ProductVariantTranslatableContent implements Node @doc(category: "Products") {
- """The ID of the product variant translatable content."""
- id: ID!
+enum WarehouseSortField @doc(category: "Products") {
+ """Sort warehouses by name."""
+ NAME
+}
- """Name of the product variant to translate."""
- name: String!
+type TranslatableItemConnection {
+ """Pagination data for this connection."""
+ pageInfo: PageInfo!
+ edges: [TranslatableItemEdge!]!
- """Returns translated product variant fields for the given language code."""
- translation(
- """A language code to return the translation for product variant."""
- languageCode: LanguageCodeEnum!
- ): ProductVariantTranslation
+ """A total count of items in the collection."""
+ totalCount: Int
+}
- """Represents a version of a product such as different size or color."""
- productVariant: ProductVariant @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
+type TranslatableItemEdge {
+ """The item at the end of the edge."""
+ node: TranslatableItem!
- """List of product variant attribute values that can be translated."""
- attributeValues: [AttributeValueTranslatableContent!]!
+ """A cursor for use in pagination."""
+ cursor: String!
}
+union TranslatableItem = ProductTranslatableContent | CollectionTranslatableContent | CategoryTranslatableContent | AttributeTranslatableContent | AttributeValueTranslatableContent | ProductVariantTranslatableContent | PageTranslatableContent | ShippingMethodTranslatableContent | VoucherTranslatableContent | MenuItemTranslatableContent | PromotionTranslatableContent | PromotionRuleTranslatableContent | SaleTranslatableContent
+
"""
Represents page's original translatable fields and related translations.
"""
@@ -8686,6 +8815,13 @@ type PageTranslatableContent implements Node @doc(category: "Pages") {
"""The ID of the page translatable content."""
id: ID!
+ """
+ The ID of the page to translate.
+
+ Added in Saleor 3.14.
+ """
+ pageId: ID!
+
"""SEO title to translate."""
seoTitle: String
@@ -8754,6 +8890,13 @@ type PageTranslation implements Node @doc(category: "Pages") {
Rich text format. For reference see https://editorjs.io/
"""
contentJson: JSONString @deprecated(reason: "This field will be removed in Saleor 4.0. Use the `content` field instead.")
+
+ """
+ Represents the page fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: PageTranslatableContent
}
"""
@@ -8943,42 +9086,18 @@ type PageType implements Node & ObjectWithMetadata @doc(category: "Pages") {
}
"""
-Represents shipping method's original translatable fields and related translations.
+Represents voucher's original translatable fields and related translations.
"""
-type ShippingMethodTranslatableContent implements Node @doc(category: "Shipping") {
- """The ID of the shipping method translatable content."""
+type VoucherTranslatableContent implements Node @doc(category: "Discounts") {
+ """The ID of the voucher translatable content."""
id: ID!
- """Shipping method name to translate."""
- name: String!
-
- """
- Shipping method description to translate.
-
- Rich text format. For reference see https://editorjs.io/
- """
- description: JSONString
-
- """Returns translated shipping method fields for the given language code."""
- translation(
- """A language code to return the translation for shipping method."""
- languageCode: LanguageCodeEnum!
- ): ShippingMethodTranslation
-
"""
- Shipping method are the methods you'll use to get customer's orders to them. They are directly exposed to the customers.
+ The ID of the voucher to translate.
- Requires one of the following permissions: MANAGE_SHIPPING.
+ Added in Saleor 3.14.
"""
- shippingMethod: ShippingMethodType @deprecated(reason: "This field will be removed in Saleor 4.0. Get model fields from the root level queries.")
-}
-
-"""
-Represents voucher's original translatable fields and related translations.
-"""
-type VoucherTranslatableContent implements Node @doc(category: "Discounts") {
- """The ID of the voucher translatable content."""
- id: ID!
+ voucherId: ID!
"""Voucher name to translate."""
name: String
@@ -9007,6 +9126,13 @@ type VoucherTranslation implements Node @doc(category: "Discounts") {
"""Translated voucher name."""
name: String
+
+ """
+ Represents the voucher fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: VoucherTranslatableContent
}
"""
@@ -9354,6 +9480,13 @@ type MenuItemTranslatableContent implements Node @doc(category: "Menu") {
"""The ID of the menu item translatable content."""
id: ID!
+ """
+ The ID of the menu item to translate.
+
+ Added in Saleor 3.14.
+ """
+ menuItemId: ID!
+
"""Name of the menu item to translate."""
name: String!
@@ -9379,6 +9512,13 @@ type MenuItemTranslation implements Node @doc(category: "Menu") {
"""Translated menu item name."""
name: String!
+
+ """
+ Represents the menu item fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: MenuItemTranslatableContent
}
"""
@@ -9528,6 +9668,9 @@ type PromotionTranslatableContent implements Node @doc(category: "Discounts") {
"""ID of the promotion translatable content."""
id: ID!
+ """ID of the promotion to translate."""
+ promotionId: ID!
+
"""Name of the promotion."""
name: String!
@@ -9566,6 +9709,13 @@ type PromotionTranslation implements Node @doc(category: "Discounts") {
Rich text format. For reference see https://editorjs.io/
"""
description: JSONString
+
+ """
+ Represents the promotion fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: PromotionTranslatableContent
}
"""
@@ -9577,6 +9727,13 @@ type PromotionRuleTranslatableContent implements Node @doc(category: "Discounts"
"""ID of the promotion rule translatable content."""
id: ID!
+ """
+ ID of the promotion rule to translate.
+
+ Added in Saleor 3.14.
+ """
+ promotionRuleId: ID!
+
"""Name of the promotion rule."""
name: String
@@ -9615,6 +9772,13 @@ type PromotionRuleTranslation implements Node @doc(category: "Discounts") {
Rich text format. For reference see https://editorjs.io/
"""
description: JSONString
+
+ """
+ Represents the promotion rule fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: PromotionRuleTranslatableContent
}
"""
@@ -9626,6 +9790,13 @@ type SaleTranslatableContent implements Node @doc(category: "Discounts") {
"""The ID of the sale translatable content."""
id: ID!
+ """
+ The ID of the sale to translate.
+
+ Added in Saleor 3.14.
+ """
+ saleId: ID!
+
"""Name of the sale to translate."""
name: String!
@@ -9657,6 +9828,13 @@ type SaleTranslation implements Node @doc(category: "Discounts") {
"""Translated name of sale."""
name: String
+
+ """
+ Represents the sale fields to translate.
+
+ Added in Saleor 3.14.
+ """
+ translatableContent: SaleTranslatableContent
}
"""
diff --git a/saleor/graphql/translations/tests/test_translations.py b/saleor/graphql/translations/tests/test_translations.py
index 59bbce2f7d..4195bcdffe 100644
--- a/saleor/graphql/translations/tests/test_translations.py
+++ b/saleor/graphql/translations/tests/test_translations.py
@@ -3206,8 +3206,10 @@ QUERY_TRANSLATION_PRODUCT = """
__typename
...on ProductTranslatableContent{
id
+ productId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3223,7 +3225,9 @@ def test_translation_query_product(
product_translation_fr,
):
product_id = graphene.Node.to_global_id("Product", product.id)
-
+ translation_id = graphene.Node.to_global_id(
+ "ProductTranslation", product_translation_fr.id
+ )
variables = {
"id": product_id,
"kind": TranslatableKinds.PRODUCT.name,
@@ -3236,7 +3240,9 @@ def test_translation_query_product(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["productId"] == product_id
assert data["name"] == product.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == product_translation_fr.name
@@ -3248,8 +3254,10 @@ QUERY_TRANSLATION_COLLECTION = """
__typename
...on CollectionTranslatableContent{
id
+ collectionId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3268,6 +3276,9 @@ def test_translation_query_collection(
channel_listing = published_collection.channel_listings.get()
channel_listing.save()
collection_id = graphene.Node.to_global_id("Collection", published_collection.id)
+ translation_id = graphene.Node.to_global_id(
+ "CollectionTranslation", collection_translation_fr.id
+ )
variables = {
"id": collection_id,
@@ -3281,7 +3292,9 @@ def test_translation_query_collection(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["collectionId"] == collection_id
assert data["name"] == published_collection.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == collection_translation_fr.name
@@ -3293,9 +3306,15 @@ QUERY_TRANSLATION_CATEGORY = """
__typename
...on CategoryTranslatableContent{
id
+ categoryId
name
translation(languageCode: $languageCode){
+ id
name
+ translatableContent {
+ id
+ name
+ }
}
}
}
@@ -3307,12 +3326,15 @@ def test_translation_query_category(
staff_api_client, category, category_translation_fr, permission_manage_translations
):
category_id = graphene.Node.to_global_id("Category", category.id)
-
+ translation_id = graphene.Node.to_global_id(
+ "CategoryTranslation", category_translation_fr.id
+ )
variables = {
"id": category_id,
"kind": TranslatableKinds.CATEGORY.name,
"languageCode": LanguageCodeEnum.FR.name,
}
+
response = staff_api_client.post_graphql(
QUERY_TRANSLATION_CATEGORY,
variables,
@@ -3320,8 +3342,10 @@ def test_translation_query_category(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["categoryId"] == category_id
assert data["name"] == category.name
assert data["translation"]["name"] == category_translation_fr.name
+ assert data["translation"]["id"] == translation_id
QUERY_TRANSLATION_ATTRIBUTE = """
@@ -3332,8 +3356,10 @@ QUERY_TRANSLATION_ATTRIBUTE = """
__typename
...on AttributeTranslatableContent{
id
+ attributeId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3347,6 +3373,9 @@ def test_translation_query_attribute(
):
attribute = translated_attribute.attribute
attribute_id = graphene.Node.to_global_id("Attribute", attribute.id)
+ translation_id = graphene.Node.to_global_id(
+ "AttributeTranslation", translated_attribute.id
+ )
variables = {
"id": attribute_id,
@@ -3360,7 +3389,9 @@ def test_translation_query_attribute(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["attributeId"] == attribute_id
assert data["name"] == attribute.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == translated_attribute.name
@@ -3372,8 +3403,10 @@ QUERY_TRANSLATION_ATTRIBUTE_VALUE = """
__typename
...on AttributeValueTranslatableContent{
id
+ attributeValueId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3391,6 +3424,9 @@ def test_translation_query_attribute_value(
attribute_value_id = graphene.Node.to_global_id(
"AttributeValue", pink_attribute_value.id
)
+ translation_id = graphene.Node.to_global_id(
+ "AttributeValueTranslation", translated_attribute_value.id
+ )
variables = {
"id": attribute_value_id,
@@ -3404,7 +3440,9 @@ def test_translation_query_attribute_value(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["attributeValueId"] == attribute_value_id
assert data["name"] == pink_attribute_value.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == translated_attribute_value.name
@@ -3416,8 +3454,10 @@ QUERY_TRANSLATION_VARIANT = """
__typename
...on ProductVariantTranslatableContent{
id
+ productVariantId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3434,6 +3474,9 @@ def test_translation_query_variant(
variant_translation_fr,
):
variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
+ translation_id = graphene.Node.to_global_id(
+ "ProductVariantTranslation", variant_translation_fr.id
+ )
variables = {
"id": variant_id,
"kind": TranslatableKinds.VARIANT.name,
@@ -3446,7 +3489,9 @@ def test_translation_query_variant(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["productVariantId"] == variant_id
assert data["name"] == variant.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == variant_translation_fr.name
@@ -3458,8 +3503,10 @@ QUERY_TRANSLATION_PAGE = """
__typename
...on PageTranslatableContent{
id
+ pageId
title
translation(languageCode: $languageCode){
+ id
title
}
}
@@ -3487,6 +3534,9 @@ def test_translation_query_page(
page.save()
page_id = graphene.Node.to_global_id("Page", page.id)
+ translation_id = graphene.Node.to_global_id(
+ "PageTranslation", page_translation_fr.id
+ )
perms = list(Permission.objects.filter(codename__in=perm_codenames))
variables = {
@@ -3499,7 +3549,9 @@ def test_translation_query_page(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["pageId"] == page_id
assert data["title"] == page.title
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["title"] == page_translation_fr.title
@@ -3511,9 +3563,11 @@ QUERY_TRANSLATION_SHIPPING_METHOD = """
__typename
...on ShippingMethodTranslatableContent{
id
+ shippingMethodId
name
description
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3539,6 +3593,9 @@ def test_translation_query_shipping_method(
shipping_method_id = graphene.Node.to_global_id(
"ShippingMethodType", shipping_method.id
)
+ translation_id = graphene.Node.to_global_id(
+ "ShippingMethodTranslation", shipping_method_translation_fr.id
+ )
perms = list(Permission.objects.filter(codename__in=perm_codenames))
variables = {
@@ -3551,8 +3608,10 @@ def test_translation_query_shipping_method(
)
content = get_graphql_content(response, ignore_errors=True)
data = content["data"]["translation"]
+ assert data["shippingMethodId"] == shipping_method_id
assert data["name"] == shipping_method.name
assert data["description"] == shipping_method.description
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == shipping_method_translation_fr.name
@@ -3564,8 +3623,10 @@ QUERY_TRANSLATION_SALE = """
__typename
...on SaleTranslatableContent{
id
+ saleId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3585,6 +3646,9 @@ def test_translation_query_sale(
promotion = promotion_converted_from_sale
promotion_translation = promotion.translations.first()
sale_id = graphene.Node.to_global_id("Sale", promotion.old_sale_id)
+ translation_id = graphene.Node.to_global_id(
+ "SaleTranslation", promotion_converted_from_sale_translation_fr.id
+ )
variables = {
"id": sale_id,
@@ -3602,7 +3666,9 @@ def test_translation_query_sale(
# then
content = get_graphql_content(response, ignore_errors=True)
data = content["data"]["translation"]
+ assert data["saleId"] == sale_id
assert data["name"] == promotion.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == promotion_translation.name
@@ -3614,8 +3680,10 @@ QUERY_TRANSLATION_VOUCHER = """
__typename
...on VoucherTranslatableContent{
id
+ voucherId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3635,6 +3703,9 @@ def test_translation_query_voucher(
staff_api_client, voucher, voucher_translation_fr, perm_codenames, return_voucher
):
voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)
+ translation_id = graphene.Node.to_global_id(
+ "VoucherTranslation", voucher_translation_fr.id
+ )
perms = list(Permission.objects.filter(codename__in=perm_codenames))
variables = {
@@ -3647,7 +3718,9 @@ def test_translation_query_voucher(
)
content = get_graphql_content(response, ignore_errors=True)
data = content["data"]["translation"]
+ assert data["voucherId"] == voucher_id
assert data["name"] == voucher.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == voucher_translation_fr.name
@@ -3659,8 +3732,10 @@ QUERY_TRANSLATION_MENU_ITEM = """
__typename
...on MenuItemTranslatableContent{
id
+ menuItemId
name
translation(languageCode: $languageCode){
+ id
name
}
}
@@ -3676,6 +3751,9 @@ def test_translation_query_menu_item(
permission_manage_translations,
):
menu_item_id = graphene.Node.to_global_id("MenuItem", menu_item.id)
+ translation_id = graphene.Node.to_global_id(
+ "MenuItemTranslation", menu_item_translation_fr.id
+ )
variables = {
"id": menu_item_id,
@@ -3689,7 +3767,9 @@ def test_translation_query_menu_item(
)
content = get_graphql_content(response)
data = content["data"]["translation"]
+ assert data["menuItemId"] == menu_item_id
assert data["name"] == menu_item.name
+ assert data["translation"]["id"] == translation_id
assert data["translation"]["name"] == menu_item_translation_fr.name
diff --git a/saleor/graphql/translations/types.py b/saleor/graphql/translations/types.py
index df4281852a..1c780cc7f0 100644
--- a/saleor/graphql/translations/types.py
+++ b/saleor/graphql/translations/types.py
@@ -19,11 +19,12 @@ from ...permission.enums import (
from ...product import models as product_models
from ...shipping import models as shipping_models
from ...site import models as site_models
-from ..attribute.dataloaders import AttributesByAttributeId
+from ..attribute.dataloaders import AttributesByAttributeId, AttributeValueByIdLoader
from ..channel import ChannelContext
from ..core.context import get_database_connection_name
from ..core.descriptions import (
ADDED_IN_39,
+ ADDED_IN_314,
ADDED_IN_317,
DEPRECATED_IN_3X_FIELD,
DEPRECATED_IN_3X_TYPE,
@@ -34,15 +35,27 @@ from ..core.fields import JSONString, PermissionsField
from ..core.tracing import traced_resolver
from ..core.types import LanguageDisplay, ModelObjectType, NonNullList
from ..core.utils import str_to_enum
+from ..discount.dataloaders import (
+ PromotionByIdLoader,
+ PromotionRuleByIdLoader,
+ VoucherByIdLoader,
+)
+from ..menu.dataloaders import MenuItemByIdLoader
from ..page.dataloaders import (
+ PageByIdLoader,
SelectedAttributesAllByPageIdLoader,
SelectedAttributesVisibleInStorefrontPageIdLoader,
)
from ..product.dataloaders import (
+ CategoryByIdLoader,
+ CollectionByIdLoader,
+ ProductByIdLoader,
+ ProductVariantByIdLoader,
SelectedAttributesAllByProductIdLoader,
SelectedAttributesByProductVariantIdLoader,
SelectedAttributesVisibleInStorefrontByProductIdLoader,
)
+from ..shipping.dataloaders import ShippingMethodByIdLoader
from ..utils import get_user_or_app_from_context
from .fields import TranslationField
@@ -100,27 +113,52 @@ class AttributeValueTranslation(
description="Translated rich-text attribute value." + RICH_CONTENT
)
plain_text = graphene.String(description="Translated plain text attribute value .")
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.AttributeValueTranslatableContent",
+ description="Represents the attribute value fields to translate."
+ + ADDED_IN_314,
+ )
class Meta:
model = attribute_models.AttributeValueTranslation
interfaces = [graphene.relay.Node]
description = "Represents attribute value translations."
+ @staticmethod
+ def resolve_translatable_content(
+ root: attribute_models.AttributeValueTranslation, info
+ ):
+ return AttributeValueByIdLoader(info.context).load(root.attribute_value_id)
+
class AttributeTranslation(BaseTranslationType[attribute_models.AttributeTranslation]):
id = graphene.GlobalID(
required=True, description="The ID of the attribute translation."
)
name = graphene.String(required=True, description="Translated attribute name.")
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.AttributeTranslatableContent",
+ description="Represents the attribute fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = attribute_models.AttributeTranslation
interfaces = [graphene.relay.Node]
description = "Represents attribute translations."
+ @staticmethod
+ def resolve_translatable_content(root: attribute_models.AttributeTranslation, info):
+ return AttributesByAttributeId(info.context).load(root.attribute_id)
+
class AttributeTranslatableContent(ModelObjectType[attribute_models.Attribute]):
- id = graphene.GlobalID(required=True, description="The ID of the attribute.")
+ id = graphene.GlobalID(
+ required=True, description="The ID of the attribute translatable content."
+ )
+ attribute_id = graphene.ID(
+ required=True,
+ description="The ID of the attribute to translate." + ADDED_IN_314,
+ )
name = graphene.String(
required=True, description="Name of the attribute to translate."
)
@@ -145,6 +183,10 @@ class AttributeTranslatableContent(ModelObjectType[attribute_models.Attribute]):
def resolve_attribute(root: attribute_models.Attribute, _info):
return root
+ @staticmethod
+ def resolve_attribute_id(root: attribute_models.Attribute, _info):
+ return graphene.Node.to_global_id("Attribute", root.id)
+
class AttributeValueTranslatableContent(
ModelObjectType[attribute_models.AttributeValue]
@@ -152,6 +194,10 @@ class AttributeValueTranslatableContent(
id = graphene.GlobalID(
required=True, description="The ID of the attribute value translatable content."
)
+ attribute_value_id = graphene.ID(
+ required=True,
+ description="The ID of the attribute value to translate." + ADDED_IN_314,
+ )
name = graphene.String(
required=True,
description="Name of the attribute value to translate.",
@@ -189,6 +235,10 @@ class AttributeValueTranslatableContent(
def resolve_attribute(root: attribute_models.AttributeValue, info):
return AttributesByAttributeId(info.context).load(root.attribute_id)
+ @staticmethod
+ def resolve_attribute_value_id(root: attribute_models.AttributeValue, _info):
+ return graphene.Node.to_global_id("AttributeValue", root.id)
+
class ProductVariantTranslation(
BaseTranslationType[product_models.ProductVariantTranslation]
@@ -199,17 +249,32 @@ class ProductVariantTranslation(
name = graphene.String(
required=True, description="Translated product variant name."
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.ProductVariantTranslatableContent",
+ description="Represents the product variant fields to translate."
+ + ADDED_IN_314,
+ )
class Meta:
model = product_models.ProductVariantTranslation
interfaces = [graphene.relay.Node]
description = "Represents product variant translations."
+ @staticmethod
+ def resolve_translatable_content(
+ root: product_models.ProductVariantTranslation, info
+ ):
+ return ProductVariantByIdLoader(info.context).load(root.product_variant_id)
+
class ProductVariantTranslatableContent(ModelObjectType[product_models.ProductVariant]):
id = graphene.GlobalID(
required=True, description="The ID of the product variant translatable content."
)
+ product_variant_id = graphene.ID(
+ required=True,
+ description="The ID of the product variant to translate." + ADDED_IN_314,
+ )
name = graphene.String(
required=True,
description="Name of the product variant to translate.",
@@ -252,6 +317,10 @@ class ProductVariantTranslatableContent(ModelObjectType[product_models.ProductVa
.then(get_translatable_attribute_values)
)
+ @staticmethod
+ def resolve_product_variant_id(root: product_models.ProductVariant, _info):
+ return graphene.Node.to_global_id("ProductVariant", root.id)
+
class ProductTranslation(BaseTranslationType[product_models.ProductTranslation]):
id = graphene.GlobalID(
@@ -269,6 +338,10 @@ class ProductTranslation(BaseTranslationType[product_models.ProductTranslation])
f"{DEPRECATED_IN_3X_FIELD} Use the `description` field instead."
),
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.ProductTranslatableContent",
+ description="Represents the product fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = product_models.ProductTranslation
@@ -280,11 +353,19 @@ class ProductTranslation(BaseTranslationType[product_models.ProductTranslation])
description = root.description
return description if description is not None else {}
+ @staticmethod
+ def resolve_translatable_content(root: product_models.ProductTranslation, info):
+ return ProductByIdLoader(info.context).load(root.product_id)
+
class ProductTranslatableContent(ModelObjectType[product_models.Product]):
id = graphene.GlobalID(
required=True, description="The ID of the product translatable content."
)
+ product_id = graphene.ID(
+ required=True,
+ description="The ID of the product to translate." + ADDED_IN_314,
+ )
seo_title = graphene.String(description="SEO title to translate.")
seo_description = graphene.String(description="SEO description to translate.")
name = graphene.String(required=True, description="Product's name to translate.")
@@ -348,6 +429,10 @@ class ProductTranslatableContent(ModelObjectType[product_models.Product]):
.then(get_translatable_attribute_values)
)
+ @staticmethod
+ def resolve_product_id(root: product_models.Product, _info):
+ return graphene.Node.to_global_id("Product", root.id)
+
class CollectionTranslation(BaseTranslationType[product_models.CollectionTranslation]):
id = graphene.GlobalID(
@@ -365,6 +450,10 @@ class CollectionTranslation(BaseTranslationType[product_models.CollectionTransla
f"{DEPRECATED_IN_3X_FIELD} Use the `description` field instead."
),
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.CollectionTranslatableContent",
+ description="Represents the collection fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = product_models.CollectionTranslation
@@ -376,11 +465,19 @@ class CollectionTranslation(BaseTranslationType[product_models.CollectionTransla
description = root.description
return description if description is not None else {}
+ @staticmethod
+ def resolve_translatable_content(root: product_models.CollectionTranslation, info):
+ return CollectionByIdLoader(info.context).load(root.collection_id)
+
class CollectionTranslatableContent(ModelObjectType[product_models.Collection]):
id = graphene.GlobalID(
required=True, description="The ID of the collection translatable content."
)
+ collection_id = graphene.ID(
+ required=True,
+ description="The ID of the collection to translate." + ADDED_IN_314,
+ )
seo_title = graphene.String(description="SEO title to translate.")
seo_description = graphene.String(description="SEO description to translate.")
name = graphene.String(required=True, description="Collection's name to translate.")
@@ -429,6 +526,10 @@ class CollectionTranslatableContent(ModelObjectType[product_models.Collection]):
description = root.description
return description if description is not None else {}
+ @staticmethod
+ def resolve_collection_id(root: product_models.Collection, _info):
+ return graphene.Node.to_global_id("Collection", root.id)
+
class CategoryTranslation(BaseTranslationType[product_models.CategoryTranslation]):
id = graphene.GlobalID(
@@ -446,6 +547,10 @@ class CategoryTranslation(BaseTranslationType[product_models.CategoryTranslation
f"{DEPRECATED_IN_3X_FIELD} Use the `description` field instead."
),
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.CategoryTranslatableContent",
+ description="Represents the category fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = product_models.CategoryTranslation
@@ -457,11 +562,19 @@ class CategoryTranslation(BaseTranslationType[product_models.CategoryTranslation
description = root.description
return description if description is not None else {}
+ @staticmethod
+ def resolve_translatable_content(root: product_models.CategoryTranslation, info):
+ return CategoryByIdLoader(info.context).load(root.category_id)
+
class CategoryTranslatableContent(ModelObjectType[product_models.Category]):
id = graphene.GlobalID(
required=True, description="The ID of the category translatable content."
)
+ category_id = graphene.ID(
+ required=True,
+ description="The ID of the category to translate." + ADDED_IN_314,
+ )
seo_title = graphene.String(description="SEO title to translate.")
seo_description = graphene.String(description="SEO description to translate.")
name = graphene.String(
@@ -501,6 +614,10 @@ class CategoryTranslatableContent(ModelObjectType[product_models.Category]):
description = root.description
return description if description is not None else {}
+ @staticmethod
+ def resolve_category_id(root: product_models.Category, _info):
+ return graphene.Node.to_global_id("Category", root.id)
+
class PageTranslation(BaseTranslationType[page_models.PageTranslation]):
id = graphene.GlobalID(required=True, description="The ID of the page translation.")
@@ -512,6 +629,10 @@ class PageTranslation(BaseTranslationType[page_models.PageTranslation]):
description="Translated description of the page." + RICH_CONTENT,
deprecation_reason=f"{DEPRECATED_IN_3X_FIELD} Use the `content` field instead.",
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.PageTranslatableContent",
+ description="Represents the page fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = page_models.PageTranslation
@@ -523,11 +644,18 @@ class PageTranslation(BaseTranslationType[page_models.PageTranslation]):
content = root.content
return content if content is not None else {}
+ @staticmethod
+ def resolve_translatable_content(root: page_models.PageTranslation, info):
+ return PageByIdLoader(info.context).load(root.page_id)
+
class PageTranslatableContent(ModelObjectType[page_models.Page]):
id = graphene.GlobalID(
required=True, description="The ID of the page translatable content."
)
+ page_id = graphene.ID(
+ required=True, description="The ID of the page to translate." + ADDED_IN_314
+ )
seo_title = graphene.String(description="SEO title to translate.")
seo_description = graphene.String(description="SEO description to translate.")
title = graphene.String(required=True, description="Page title to translate.")
@@ -594,23 +722,39 @@ class PageTranslatableContent(ModelObjectType[page_models.Page]):
.then(get_translatable_attribute_values)
)
+ @staticmethod
+ def resolve_page_id(root: page_models.Page, _info):
+ return graphene.Node.to_global_id("Page", root.id)
+
class VoucherTranslation(BaseTranslationType[discount_models.VoucherTranslation]):
id = graphene.GlobalID(
required=True, description="The ID of the voucher translation."
)
name = graphene.String(description="Translated voucher name.")
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.VoucherTranslatableContent",
+ description="Represents the voucher fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = discount_models.VoucherTranslation
interfaces = [graphene.relay.Node]
description = "Represents voucher translations."
+ @staticmethod
+ def resolve_translatable_content(root: discount_models.VoucherTranslation, info):
+ return VoucherByIdLoader(info.context).load(root.voucher_id)
+
class VoucherTranslatableContent(ModelObjectType[discount_models.Voucher]):
id = graphene.GlobalID(
required=True, description="The ID of the voucher translatable content."
)
+ voucher_id = graphene.ID(
+ required=True,
+ description="The ID of the voucher to translate." + ADDED_IN_314,
+ )
name = graphene.String(description="Voucher name to translate.")
translation = TranslationField(VoucherTranslation, type_name="voucher")
voucher = PermissionsField(
@@ -638,10 +782,18 @@ class VoucherTranslatableContent(ModelObjectType[discount_models.Voucher]):
def resolve_voucher(root: discount_models.Voucher, _info):
return ChannelContext(node=root, channel_slug=None)
+ @staticmethod
+ def resolve_voucher_id(root: discount_models.Voucher, _info):
+ return graphene.Node.to_global_id("Voucher", root.id)
+
class SaleTranslation(BaseTranslationType[discount_models.PromotionTranslation]):
id = graphene.GlobalID(required=True, description="The ID of the sale translation.")
name = graphene.String(description="Translated name of sale.")
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.SaleTranslatableContent",
+ description="Represents the sale fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = discount_models.PromotionTranslation
@@ -652,11 +804,19 @@ class SaleTranslation(BaseTranslationType[discount_models.PromotionTranslation])
+ " Use `PromotionTranslation` instead."
)
+ @staticmethod
+ def resolve_translatable_content(root: discount_models.PromotionTranslation, info):
+ return PromotionByIdLoader(info.context).load(root.promotion_id)
+
class SaleTranslatableContent(ModelObjectType[discount_models.Promotion]):
id = graphene.GlobalID(
required=True, description="The ID of the sale translatable content."
)
+ sale_id = graphene.ID(
+ required=True,
+ description="The ID of the sale to translate." + ADDED_IN_314,
+ )
name = graphene.String(required=True, description="Name of the sale to translate.")
translation = TranslationField(SaleTranslation, type_name="sale")
sale = PermissionsField(
@@ -684,6 +844,10 @@ class SaleTranslatableContent(ModelObjectType[discount_models.Promotion]):
def resolve_sale(root: discount_models.Promotion, _info):
return ChannelContext(node=root, channel_slug=None)
+ @staticmethod
+ def resolve_sale_id(root: discount_models.Promotion, _info):
+ return graphene.Node.to_global_id("Sale", root.old_sale_id)
+
class ShopTranslation(BaseTranslationType[site_models.SiteSettingsTranslation]):
id = graphene.GlobalID(required=True, description="The ID of the shop translation.")
@@ -705,17 +869,29 @@ class MenuItemTranslation(BaseTranslationType[menu_models.MenuItemTranslation]):
required=True, description="The ID of the menu item translation."
)
name = graphene.String(required=True, description="Translated menu item name.")
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.MenuItemTranslatableContent",
+ description="Represents the menu item fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = menu_models.MenuItemTranslation
interfaces = [graphene.relay.Node]
description = "Represents menu item translations."
+ @staticmethod
+ def resolve_translatable_content(root: menu_models.MenuItemTranslation, info):
+ return MenuItemByIdLoader(info.context).load(root.menu_item_id)
+
class MenuItemTranslatableContent(ModelObjectType[menu_models.MenuItem]):
id = graphene.GlobalID(
required=True, description="The ID of the menu item translatable content."
)
+ menu_item_id = graphene.ID(
+ required=True,
+ description="The ID of the menu item to translate." + ADDED_IN_314,
+ )
name = graphene.String(
required=True, description="Name of the menu item to translate."
)
@@ -743,6 +919,10 @@ class MenuItemTranslatableContent(ModelObjectType[menu_models.MenuItem]):
def resolve_menu_item(root: menu_models.MenuItem, _info):
return ChannelContext(node=root, channel_slug=None)
+ @staticmethod
+ def resolve_menu_item_id(root: menu_models.MenuItem, _info):
+ return graphene.Node.to_global_id("MenuItem", root.id)
+
class ShippingMethodTranslation(
BaseTranslationType[shipping_models.ShippingMethodTranslation]
@@ -756,12 +936,23 @@ class ShippingMethodTranslation(
description = JSONString(
description="Translated description of the shipping method." + RICH_CONTENT
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.ShippingMethodTranslatableContent",
+ description="Represents the shipping method fields to translate."
+ + ADDED_IN_314,
+ )
class Meta:
model = shipping_models.ShippingMethodTranslation
interfaces = [graphene.relay.Node]
description = "Represents shipping method translations."
+ @staticmethod
+ def resolve_translatable_content(
+ root: shipping_models.ShippingMethodTranslation, info
+ ):
+ return ShippingMethodByIdLoader(info.context).load(root.shipping_method_id)
+
class ShippingMethodTranslatableContent(
ModelObjectType[shipping_models.ShippingMethod]
@@ -769,6 +960,10 @@ class ShippingMethodTranslatableContent(
id = graphene.GlobalID(
required=True, description="The ID of the shipping method translatable content."
)
+ shipping_method_id = graphene.ID(
+ required=True,
+ description="The ID of the shipping method to translate." + ADDED_IN_314,
+ )
name = graphene.String(
required=True, description="Shipping method name to translate."
)
@@ -804,6 +999,10 @@ class ShippingMethodTranslatableContent(
def resolve_shipping_method(root: shipping_models.ShippingMethod, _info):
return ChannelContext(node=root, channel_slug=None)
+ @staticmethod
+ def resolve_shipping_method_id(root: shipping_models.ShippingMethod, _info):
+ return graphene.Node.to_global_id("ShippingMethodType", root.id)
+
class PromotionTranslation(BaseTranslationType[discount_models.PromotionTranslation]):
id = graphene.GlobalID(
@@ -813,17 +1012,28 @@ class PromotionTranslation(BaseTranslationType[discount_models.PromotionTranslat
description = JSONString(
description="Translated description of the promotion." + RICH_CONTENT
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.PromotionTranslatableContent",
+ description="Represents the promotion fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = discount_models.Promotion
interfaces = [graphene.relay.Node]
description = "Represents promotion translations." + ADDED_IN_317
+ @staticmethod
+ def resolve_translatable_content(root: discount_models.PromotionTranslation, info):
+ return PromotionByIdLoader(info.context).load(root.promotion_id)
+
class PromotionTranslatableContent(ModelObjectType[discount_models.Promotion]):
id = graphene.GlobalID(
required=True, description="ID of the promotion translatable content."
)
+ promotion_id = graphene.ID(
+ required=True, description="ID of the promotion to translate."
+ )
name = graphene.String(required=True, description="Name of the promotion.")
description = JSONString(description="Description of the promotion." + RICH_CONTENT)
translation = TranslationField(PromotionTranslation, type_name="promotion")
@@ -836,6 +1046,10 @@ class PromotionTranslatableContent(ModelObjectType[discount_models.Promotion]):
"and related translations." + ADDED_IN_317
)
+ @staticmethod
+ def resolve_promotion_id(root: discount_models.Promotion, _info):
+ return graphene.Node.to_global_id("Promotion", root.id)
+
class PromotionRuleTranslation(
BaseTranslationType[discount_models.PromotionTranslation]
@@ -847,17 +1061,31 @@ class PromotionRuleTranslation(
description = JSONString(
description="Translated description of the promotion rule." + RICH_CONTENT
)
+ translatable_content = graphene.Field(
+ "saleor.graphql.translations.types.PromotionRuleTranslatableContent",
+ description="Represents the promotion rule fields to translate." + ADDED_IN_314,
+ )
class Meta:
model = discount_models.PromotionRule
interfaces = [graphene.relay.Node]
description = "Represents promotion rule translations." + ADDED_IN_317
+ @staticmethod
+ def resolve_translatable_content(
+ root: discount_models.PromotionRuleTranslation, info
+ ):
+ return PromotionRuleByIdLoader(info.context).load(root.promotion_rule_id)
+
class PromotionRuleTranslatableContent(ModelObjectType[discount_models.Promotion]):
id = graphene.GlobalID(
required=True, description="ID of the promotion rule translatable content."
)
+ promotion_rule_id = graphene.ID(
+ required=True,
+ description="ID of the promotion rule to translate." + ADDED_IN_314,
+ )
name = graphene.String(description="Name of the promotion rule.")
description = JSONString(
description="Description of the promotion rule." + RICH_CONTENT
@@ -871,3 +1099,7 @@ class PromotionRuleTranslatableContent(ModelObjectType[discount_models.Promotion
"Represents promotion rule's original translatable fields "
"and related translations." + ADDED_IN_317
)
+
+ @staticmethod
+ def resolve_promotion_rule_id(root: discount_models.PromotionRule, _info):
+ return graphene.Node.to_global_id("PromotionRule", root.id)
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py b/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py
index 0ab0f291ce..00c6e43beb 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/fixtures.py
@@ -942,6 +942,110 @@ def subscription_translation_created_webhook(subscription_webhook):
)
+def subscription_product_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_PRODUCT,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_product_variant_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_PRODUCT_VARIANT,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_collection_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_COLLECTION,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_category_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_CATEGORY,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_attribute_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_ATTRIBUTE,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_attribute_value_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_ATTRIBUTE_VALUE,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_page_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_PAGE,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_shipping_method_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_SHIPPING_METHOD,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_promotion_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_PROMOTION,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_sale_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_SALE,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_promotion_rule_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_PROMOTION_RULE,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_voucher_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_VOUCHER,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
+def subscription_menu_item_translation_created_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_CREATED_MENU_ITEM,
+ WebhookEventAsyncType.TRANSLATION_CREATED,
+ )
+
+
@pytest.fixture
def subscription_translation_updated_webhook(subscription_webhook):
return subscription_webhook(
@@ -950,6 +1054,102 @@ def subscription_translation_updated_webhook(subscription_webhook):
)
+def subscription_product_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_PRODUCT,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_product_variant_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_PRODUCT_VARIANT,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_collection_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_COLLECTION,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_category_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_CATEGORY,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_attribute_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_ATTRIBUTE,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_attribute_value_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_ATTRIBUTE_VALUE,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_page_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_PAGE,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_shipping_method_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_SHIPPING_METHOD,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_promotion_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_PROMOTION,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_promotion_rule_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_PROMOTION_RULE,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_voucher_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_VOUCHER,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
+def subscription_menu_item_translation_updated_webhook(subscription_webhook):
+ return subscription_webhook(
+ queries.TRANSLATION_UPDATED_MENU_ITEM,
+ WebhookEventAsyncType.TRANSLATION_UPDATED,
+ )
+
+
@pytest.fixture
def subscription_warehouse_created_webhook(subscription_webhook):
return subscription_webhook(
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py b/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py
index 91c3138406..2a141a325b 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/subscription_queries.py
@@ -1,4 +1,9 @@
+from enum import Enum
+
+from graphene.utils.str_converters import to_snake_case
+
from .....graphql.tests.queries import fragments
+from .....graphql.webhook.subscription_types import TRANSLATIONS_TYPES_MAP
ACCOUNT_CONFIRMATION_REQUESTED = (
fragments.CUSTOMER_DETAILS
@@ -2035,6 +2040,140 @@ subscription {
}
"""
+TranslationTypes = Enum(
+ "TranslationTypes",
+ {
+ to_snake_case(k.__name__).upper(): k.__name__
+ for k in TRANSLATIONS_TYPES_MAP.keys()
+ },
+)
+
+
+class TranslationQueryType(Enum):
+ CREATED = "TranslationCreated"
+ UPDATED = "TranslationUpdated"
+
+
+def build_translation_query(
+ type: TranslationTypes,
+ query_type: TranslationQueryType,
+ translated_object_id: str,
+) -> str:
+ return ( # noqa: UP031
+ """
+ subscription {
+ event {
+ ... on %s {
+ translation {
+ ... on %s {
+ id
+ name
+ translatableContent {
+ %s
+ name
+ }
+ }
+ }
+ }
+ }
+ }
+ """
+ ) % (query_type.value, type.value, translated_object_id)
+
+
+TRANSLATION_CREATED_PRODUCT = build_translation_query(
+ TranslationTypes.PRODUCT_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "productId",
+)
+TRANSLATION_CREATED_PRODUCT_VARIANT = build_translation_query(
+ TranslationTypes.PRODUCT_VARIANT_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "productVariantId",
+)
+TRANSLATION_CREATED_COLLECTION = build_translation_query(
+ TranslationTypes.COLLECTION_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "collectionId",
+)
+TRANSLATION_CREATED_CATEGORY = build_translation_query(
+ TranslationTypes.CATEGORY_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "categoryId",
+)
+TRANSLATION_CREATED_ATTRIBUTE = build_translation_query(
+ TranslationTypes.ATTRIBUTE_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "attributeId",
+)
+TRANSLATION_CREATED_ATTRIBUTE_VALUE = build_translation_query(
+ TranslationTypes.ATTRIBUTE_VALUE_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "attributeValueId",
+)
+TRANSLATION_CREATED_SHIPPING_METHOD = build_translation_query(
+ TranslationTypes.SHIPPING_METHOD_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "shippingMethodId",
+)
+TRANSLATION_CREATED_PROMOTION = build_translation_query(
+ TranslationTypes.PROMOTION_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "promotionId",
+)
+TRANSLATION_CREATED_PROMOTION_RULE = build_translation_query(
+ TranslationTypes.PROMOTION_RULE_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "promotionRuleId",
+)
+TRANSLATION_CREATED_VOUCHER = build_translation_query(
+ TranslationTypes.VOUCHER_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "voucherId",
+)
+TRANSLATION_CREATED_MENU_ITEM = build_translation_query(
+ TranslationTypes.MENU_ITEM_TRANSLATION,
+ TranslationQueryType.CREATED,
+ "menuItemId",
+)
+TRANSLATION_CREATED_PAGE = """
+ subscription {
+ event {
+ ... on TranslationCreated {
+ translation {
+ ... on PageTranslation {
+ id
+ title
+ translatableContent {
+ pageId
+ title
+ }
+ }
+ }
+ }
+ }
+ }
+"""
+TRANSLATION_CREATED_SALE = """
+ subscription {
+ event {
+ ... on TranslationCreated {
+ translation {
+ ... on SaleTranslation {
+ __typename
+ id
+ name
+ translatableContent {
+ saleId
+ name
+ }
+ }
+ }
+ }
+ }
+ }
+"""
+
TRANSLATION_UPDATED = """
subscription {
event {
@@ -2087,6 +2226,80 @@ subscription {
}
"""
+TRANSLATION_UPDATED_PRODUCT = build_translation_query(
+ TranslationTypes.PRODUCT_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "productId",
+)
+TRANSLATION_UPDATED_PRODUCT_VARIANT = build_translation_query(
+ TranslationTypes.PRODUCT_VARIANT_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "productVariantId",
+)
+TRANSLATION_UPDATED_COLLECTION = build_translation_query(
+ TranslationTypes.COLLECTION_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "collectionId",
+)
+TRANSLATION_UPDATED_CATEGORY = build_translation_query(
+ TranslationTypes.CATEGORY_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "categoryId",
+)
+TRANSLATION_UPDATED_ATTRIBUTE = build_translation_query(
+ TranslationTypes.ATTRIBUTE_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "attributeId",
+)
+TRANSLATION_UPDATED_ATTRIBUTE_VALUE = build_translation_query(
+ TranslationTypes.ATTRIBUTE_VALUE_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "attributeValueId",
+)
+TRANSLATION_UPDATED_SHIPPING_METHOD = build_translation_query(
+ TranslationTypes.SHIPPING_METHOD_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "shippingMethodId",
+)
+TRANSLATION_UPDATED_PROMOTION = build_translation_query(
+ TranslationTypes.PROMOTION_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "promotionId",
+)
+TRANSLATION_UPDATED_PROMOTION_RULE = build_translation_query(
+ TranslationTypes.PROMOTION_RULE_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "promotionRuleId",
+)
+TRANSLATION_UPDATED_VOUCHER = build_translation_query(
+ TranslationTypes.VOUCHER_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "voucherId",
+)
+TRANSLATION_UPDATED_MENU_ITEM = build_translation_query(
+ TranslationTypes.MENU_ITEM_TRANSLATION,
+ TranslationQueryType.UPDATED,
+ "menuItemId",
+)
+TRANSLATION_UPDATED_PAGE = """
+ subscription {
+ event {
+ ... on TranslationUpdated {
+ translation {
+ ... on PageTranslation {
+ id
+ title
+ translatableContent {
+ pageId
+ title
+ }
+ }
+ }
+ }
+ }
+ }
+"""
+
TEST_VALID_SUBSCRIPTION = """
subscription{
event{
diff --git a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py
index 6d26578051..03070f4cd0 100644
--- a/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py
+++ b/saleor/plugins/webhook/tests/subscription_webhooks/test_create_deliveries_for_translation_subscription.py
@@ -9,18 +9,31 @@ from .....webhook.transport.asynchronous.transport import (
def test_translation_created_product(
- product_translation_fr, subscription_translation_created_webhook
+ product_translation_fr, subscription_product_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_product_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"ProductTranslation", product_translation_fr.id
)
+ product = product_translation_fr.product
+ product_id = graphene.Node.to_global_id("Product", product.id)
deliveries = create_deliveries_for_subscriptions(
event_type, product_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": product_translation_fr.name,
+ "translatableContent": {
+ "productId": product_id,
+ "name": product.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -28,18 +41,31 @@ def test_translation_created_product(
def test_translation_created_product_variant(
- variant_translation_fr, subscription_translation_created_webhook
+ variant_translation_fr, subscription_product_variant_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_product_variant_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"ProductVariantTranslation", variant_translation_fr.id
)
+ variant = variant_translation_fr.product_variant
+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
deliveries = create_deliveries_for_subscriptions(
event_type, variant_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": variant_translation_fr.name,
+ "translatableContent": {
+ "productVariantId": variant_id,
+ "name": variant.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -47,18 +73,31 @@ def test_translation_created_product_variant(
def test_translation_created_collection(
- collection_translation_fr, subscription_translation_created_webhook
+ collection_translation_fr, subscription_collection_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_collection_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"CollectionTranslation", collection_translation_fr.id
)
+ collection = collection_translation_fr.collection
+ collection_id = graphene.Node.to_global_id("Collection", collection.id)
deliveries = create_deliveries_for_subscriptions(
event_type, collection_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": collection_translation_fr.name,
+ "translatableContent": {
+ "collectionId": collection_id,
+ "name": collection.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -66,18 +105,31 @@ def test_translation_created_collection(
def test_translation_created_category(
- category_translation_fr, subscription_translation_created_webhook
+ category_translation_fr, subscription_category_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_category_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"CategoryTranslation", category_translation_fr.id
)
+ category = category_translation_fr.category
+ category_id = graphene.Node.to_global_id("Category", category.id)
deliveries = create_deliveries_for_subscriptions(
event_type, category_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": category_translation_fr.name,
+ "translatableContent": {
+ "categoryId": category_id,
+ "name": category.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -85,18 +137,31 @@ def test_translation_created_category(
def test_translation_created_attribute(
- translated_attribute, subscription_translation_created_webhook
+ translated_attribute, subscription_attribute_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_attribute_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"AttributeTranslation", translated_attribute.id
)
+ attribute = translated_attribute.attribute
+ attribute_id = graphene.Node.to_global_id("Attribute", attribute.id)
deliveries = create_deliveries_for_subscriptions(
event_type, translated_attribute, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": translated_attribute.name,
+ "translatableContent": {
+ "attributeId": attribute_id,
+ "name": attribute.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -104,18 +169,33 @@ def test_translation_created_attribute(
def test_translation_created_attribute_value(
- translated_attribute_value, subscription_translation_created_webhook
+ translated_attribute_value, subscription_attribute_value_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_attribute_value_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"AttributeValueTranslation", translated_attribute_value.id
)
+ attribute_value = translated_attribute_value.attribute_value
+ attribute_value_id = graphene.Node.to_global_id(
+ "AttributeValue", attribute_value.id
+ )
deliveries = create_deliveries_for_subscriptions(
event_type, translated_attribute_value, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": translated_attribute_value.name,
+ "translatableContent": {
+ "attributeValueId": attribute_value_id,
+ "name": attribute_value.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -123,18 +203,31 @@ def test_translation_created_attribute_value(
def test_translation_created_page(
- page_translation_fr, subscription_translation_created_webhook
+ page_translation_fr, subscription_page_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_page_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"PageTranslation", page_translation_fr.id
)
+ page = page_translation_fr.page
+ page_id = graphene.Node.to_global_id("Page", page.id)
deliveries = create_deliveries_for_subscriptions(
event_type, page_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "title": page_translation_fr.title,
+ "translatableContent": {
+ "pageId": page_id,
+ "title": page.title,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -142,18 +235,34 @@ def test_translation_created_page(
def test_translation_created_shipping_method(
- shipping_method_translation_fr, subscription_translation_created_webhook
+ shipping_method_translation_fr,
+ subscription_shipping_method_translation_created_webhook,
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_shipping_method_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"ShippingMethodTranslation", shipping_method_translation_fr.id
)
+ shipping_method = shipping_method_translation_fr.shipping_method
+ shipping_method_id = graphene.Node.to_global_id(
+ "ShippingMethodType", shipping_method.id
+ )
deliveries = create_deliveries_for_subscriptions(
event_type, shipping_method_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": shipping_method_translation_fr.name,
+ "translatableContent": {
+ "shippingMethodId": shipping_method_id,
+ "name": shipping_method.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -161,13 +270,15 @@ def test_translation_created_shipping_method(
def test_translation_created_promotion(
- promotion_translation_fr, subscription_translation_created_webhook
+ promotion_translation_fr, subscription_promotion_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_promotion_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"PromotionTranslation", promotion_translation_fr.id
)
+ promotion = promotion_translation_fr.promotion
+ promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
deliveries = create_deliveries_for_subscriptions(
event_type, promotion_translation_fr, webhooks
)
@@ -176,7 +287,11 @@ def test_translation_created_promotion(
{
"translation": {
"id": translation_id,
- "__typename": "PromotionTranslation",
+ "name": promotion_translation_fr.name,
+ "translatableContent": {
+ "promotionId": promotion_id,
+ "name": promotion.name,
+ },
}
}
)
@@ -188,19 +303,26 @@ def test_translation_created_promotion(
def test_translation_created_promotion_converted_from_sale(
promotion_converted_from_sale_translation_fr,
- subscription_translation_created_webhook,
+ subscription_sale_translation_created_webhook,
):
translation = promotion_converted_from_sale_translation_fr
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_sale_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id("SaleTranslation", translation.id)
+ promotion = promotion_converted_from_sale_translation_fr.promotion
+ promotion_id = graphene.Node.to_global_id("Sale", promotion.old_sale_id)
deliveries = create_deliveries_for_subscriptions(event_type, translation, webhooks)
expected_payload = json.dumps(
{
"translation": {
- "id": translation_id,
"__typename": "SaleTranslation",
+ "id": translation_id,
+ "name": promotion_converted_from_sale_translation_fr.name,
+ "translatableContent": {
+ "saleId": promotion_id,
+ "name": promotion.name,
+ },
}
}
)
@@ -211,18 +333,32 @@ def test_translation_created_promotion_converted_from_sale(
def test_translation_created_promotion_rule(
- promotion_rule_translation_fr, subscription_translation_created_webhook
+ promotion_rule_translation_fr,
+ subscription_promotion_rule_translation_created_webhook,
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_promotion_rule_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"PromotionRuleTranslation", promotion_rule_translation_fr.id
)
+ promotion_rule = promotion_rule_translation_fr.promotion_rule
+ promotion_rule_id = graphene.Node.to_global_id("PromotionRule", promotion_rule.id)
deliveries = create_deliveries_for_subscriptions(
event_type, promotion_rule_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": promotion_rule_translation_fr.name,
+ "translatableContent": {
+ "promotionRuleId": promotion_rule_id,
+ "name": promotion_rule.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -230,18 +366,31 @@ def test_translation_created_promotion_rule(
def test_translation_created_voucher(
- voucher_translation_fr, subscription_translation_created_webhook
+ voucher_translation_fr, subscription_voucher_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_voucher_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"VoucherTranslation", voucher_translation_fr.id
)
+ voucher = voucher_translation_fr.voucher
+ voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)
deliveries = create_deliveries_for_subscriptions(
event_type, voucher_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": voucher_translation_fr.name,
+ "translatableContent": {
+ "voucherId": voucher_id,
+ "name": voucher.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -249,18 +398,31 @@ def test_translation_created_voucher(
def test_translation_created_menu_item(
- menu_item_translation_fr, subscription_translation_created_webhook
+ menu_item_translation_fr, subscription_menu_item_translation_created_webhook
):
- webhooks = [subscription_translation_created_webhook]
+ webhooks = [subscription_menu_item_translation_created_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_CREATED
translation_id = graphene.Node.to_global_id(
"MenuItemTranslation", menu_item_translation_fr.id
)
+ menu_item = menu_item_translation_fr.menu_item
+ menu_item_id = graphene.Node.to_global_id("MenuItem", menu_item.id)
deliveries = create_deliveries_for_subscriptions(
event_type, menu_item_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": menu_item_translation_fr.name,
+ "translatableContent": {
+ "menuItemId": menu_item_id,
+ "name": menu_item.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -268,18 +430,31 @@ def test_translation_created_menu_item(
def test_translation_updated_product(
- product_translation_fr, subscription_translation_updated_webhook
+ product_translation_fr, subscription_product_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_product_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"ProductTranslation", product_translation_fr.id
)
+ product = product_translation_fr.product
+ product_id = graphene.Node.to_global_id("Product", product.id)
deliveries = create_deliveries_for_subscriptions(
event_type, product_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": product_translation_fr.name,
+ "translatableContent": {
+ "productId": product_id,
+ "name": product.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -287,18 +462,31 @@ def test_translation_updated_product(
def test_translation_updated_product_variant(
- variant_translation_fr, subscription_translation_updated_webhook
+ variant_translation_fr, subscription_product_variant_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_product_variant_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"ProductVariantTranslation", variant_translation_fr.id
)
+ variant = variant_translation_fr.product_variant
+ variant_id = graphene.Node.to_global_id("ProductVariant", variant.id)
deliveries = create_deliveries_for_subscriptions(
event_type, variant_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": variant_translation_fr.name,
+ "translatableContent": {
+ "productVariantId": variant_id,
+ "name": variant.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -306,18 +494,31 @@ def test_translation_updated_product_variant(
def test_translation_updated_collection(
- collection_translation_fr, subscription_translation_updated_webhook
+ collection_translation_fr, subscription_collection_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_collection_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"CollectionTranslation", collection_translation_fr.id
)
+ collection = collection_translation_fr.collection
+ collection_id = graphene.Node.to_global_id("Collection", collection.id)
deliveries = create_deliveries_for_subscriptions(
event_type, collection_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": collection_translation_fr.name,
+ "translatableContent": {
+ "collectionId": collection_id,
+ "name": collection.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -325,18 +526,31 @@ def test_translation_updated_collection(
def test_translation_updated_category(
- category_translation_fr, subscription_translation_updated_webhook
+ category_translation_fr, subscription_category_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_category_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"CategoryTranslation", category_translation_fr.id
)
+ category = category_translation_fr.category
+ category_id = graphene.Node.to_global_id("Category", category.id)
deliveries = create_deliveries_for_subscriptions(
event_type, category_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": category_translation_fr.name,
+ "translatableContent": {
+ "categoryId": category_id,
+ "name": category.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -344,18 +558,31 @@ def test_translation_updated_category(
def test_translation_updated_attribute(
- translated_attribute, subscription_translation_updated_webhook
+ translated_attribute, subscription_attribute_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_attribute_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"AttributeTranslation", translated_attribute.id
)
+ attribute = translated_attribute.attribute
+ attribute_id = graphene.Node.to_global_id("Attribute", attribute.id)
deliveries = create_deliveries_for_subscriptions(
event_type, translated_attribute, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": translated_attribute.name,
+ "translatableContent": {
+ "attributeId": attribute_id,
+ "name": attribute.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -363,18 +590,33 @@ def test_translation_updated_attribute(
def test_translation_updated_attribute_value(
- translated_attribute_value, subscription_translation_updated_webhook
+ translated_attribute_value, subscription_attribute_value_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_attribute_value_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"AttributeValueTranslation", translated_attribute_value.id
)
+ attribute_value = translated_attribute_value.attribute_value
+ attribute_value_id = graphene.Node.to_global_id(
+ "AttributeValue", attribute_value.id
+ )
deliveries = create_deliveries_for_subscriptions(
event_type, translated_attribute_value, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": translated_attribute_value.name,
+ "translatableContent": {
+ "attributeValueId": attribute_value_id,
+ "name": attribute_value.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -382,18 +624,31 @@ def test_translation_updated_attribute_value(
def test_translation_updated_page(
- page_translation_fr, subscription_translation_updated_webhook
+ page_translation_fr, subscription_page_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_page_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"PageTranslation", page_translation_fr.id
)
+ page = page_translation_fr.page
+ page_id = graphene.Node.to_global_id("Page", page.id)
deliveries = create_deliveries_for_subscriptions(
event_type, page_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "title": page_translation_fr.title,
+ "translatableContent": {
+ "pageId": page_id,
+ "title": page.title,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -401,18 +656,34 @@ def test_translation_updated_page(
def test_translation_updated_shipping_method(
- shipping_method_translation_fr, subscription_translation_updated_webhook
+ shipping_method_translation_fr,
+ subscription_shipping_method_translation_updated_webhook,
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_shipping_method_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"ShippingMethodTranslation", shipping_method_translation_fr.id
)
+ shipping_method = shipping_method_translation_fr.shipping_method
+ shipping_method_id = graphene.Node.to_global_id(
+ "ShippingMethodType", shipping_method.id
+ )
deliveries = create_deliveries_for_subscriptions(
event_type, shipping_method_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": shipping_method_translation_fr.name,
+ "translatableContent": {
+ "shippingMethodId": shipping_method_id,
+ "name": shipping_method.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -420,19 +691,30 @@ def test_translation_updated_shipping_method(
def test_translation_updated_promotion(
- promotion_translation_fr, subscription_translation_updated_webhook
+ promotion_translation_fr, subscription_promotion_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_promotion_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"PromotionTranslation", promotion_translation_fr.id
)
+ promotion = promotion_translation_fr.promotion
+ promotion_id = graphene.Node.to_global_id("Promotion", promotion.id)
deliveries = create_deliveries_for_subscriptions(
event_type, promotion_translation_fr, webhooks
)
expected_payload = json.dumps(
- {"translation": {"id": translation_id, "__typename": "PromotionTranslation"}}
+ {
+ "translation": {
+ "id": translation_id,
+ "name": promotion_translation_fr.name,
+ "translatableContent": {
+ "promotionId": promotion_id,
+ "name": promotion.name,
+ },
+ }
+ }
)
assert deliveries[0].payload.payload == expected_payload
@@ -441,18 +723,32 @@ def test_translation_updated_promotion(
def test_translation_updated_promotion_rule(
- promotion_rule_translation_fr, subscription_translation_updated_webhook
+ promotion_rule_translation_fr,
+ subscription_promotion_rule_translation_updated_webhook,
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_promotion_rule_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"PromotionRuleTranslation", promotion_rule_translation_fr.id
)
+ promotion_rule = promotion_rule_translation_fr.promotion_rule
+ promotion_rule_id = graphene.Node.to_global_id("PromotionRule", promotion_rule.id)
deliveries = create_deliveries_for_subscriptions(
event_type, promotion_rule_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": promotion_rule_translation_fr.name,
+ "translatableContent": {
+ "promotionRuleId": promotion_rule_id,
+ "name": promotion_rule.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -460,18 +756,31 @@ def test_translation_updated_promotion_rule(
def test_translation_updated_voucher(
- voucher_translation_fr, subscription_translation_updated_webhook
+ voucher_translation_fr, subscription_voucher_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_voucher_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"VoucherTranslation", voucher_translation_fr.id
)
+ voucher = voucher_translation_fr.voucher
+ voucher_id = graphene.Node.to_global_id("Voucher", voucher.id)
deliveries = create_deliveries_for_subscriptions(
event_type, voucher_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": voucher_translation_fr.name,
+ "translatableContent": {
+ "voucherId": voucher_id,
+ "name": voucher.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)
@@ -479,18 +788,31 @@ def test_translation_updated_voucher(
def test_translation_updated_menu_item(
- menu_item_translation_fr, subscription_translation_updated_webhook
+ menu_item_translation_fr, subscription_menu_item_translation_updated_webhook
):
- webhooks = [subscription_translation_updated_webhook]
+ webhooks = [subscription_menu_item_translation_updated_webhook]
event_type = WebhookEventAsyncType.TRANSLATION_UPDATED
translation_id = graphene.Node.to_global_id(
"MenuItemTranslation", menu_item_translation_fr.id
)
+ menu_item = menu_item_translation_fr.menu_item
+ menu_item_id = graphene.Node.to_global_id("MenuItem", menu_item.id)
deliveries = create_deliveries_for_subscriptions(
event_type, menu_item_translation_fr, webhooks
)
- expected_payload = json.dumps({"translation": {"id": translation_id}})
+ expected_payload = json.dumps(
+ {
+ "translation": {
+ "id": translation_id,
+ "name": menu_item_translation_fr.name,
+ "translatableContent": {
+ "menuItemId": menu_item_id,
+ "name": menu_item.name,
+ },
+ }
+ }
+ )
assert deliveries[0].payload.payload == expected_payload
assert len(deliveries) == len(webhooks)