Skip to content

Commit

Permalink
Add names of attributes translations (saleor#2433)
Browse files Browse the repository at this point in the history
* Add names of attributes translations

* Support plain text attributes translation

* Fix translation field type

* Refactor attribute translations input data

* Refactor translation fields code

* Fix translation fields invalid skeleton display
  • Loading branch information
orzechdev authored Nov 4, 2022
1 parent dc5a6ac commit 7963836
Show file tree
Hide file tree
Showing 16 changed files with 205 additions and 241 deletions.
16 changes: 16 additions & 0 deletions introspection.json
Original file line number Diff line number Diff line change
Expand Up @@ -9357,6 +9357,22 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "attribute",
"description": "Represents a value of an attribute.",
"args": [],
"type": {
"kind": "NON_NULL",
"name": null,
"ofType": {
"kind": "OBJECT",
"name": "AttributeTranslatableContent",
"ofType": null
}
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "attributeValue",
"description": "Represents a value of an attribute.",
Expand Down
8 changes: 4 additions & 4 deletions locale/defaultMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3460,10 +3460,6 @@
"context": "window title",
"string": "Create Product"
},
"PajjqE": {
"context": "attribute list",
"string": "Attribute {number}"
},
"PbQJY5": {
"context": "section header",
"string": "Saleor Apps"
Expand Down Expand Up @@ -7882,6 +7878,10 @@
"context": "attribute type",
"string": "Content Attribute"
},
"zgqPGF": {
"context": "attribute list",
"string": "Attribute {name}"
},
"zjHH6b": {
"context": "sale start date",
"string": "Started"
Expand Down
3 changes: 3 additions & 0 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,9 @@ type AttributeValueTranslatableContent implements Node {
languageCode: LanguageCodeEnum!
): AttributeValueTranslation

"""Represents an attribute."""
attribute: Attribute!

"""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.")
}
Expand Down
98 changes: 31 additions & 67 deletions src/fragments/translations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
import { gql } from "@apollo/client";

export const attributeValueTranslatableFragment = gql`
fragment AttributeValueTranslatable on AttributeValueTranslatableContent {
id
name
plainText
richText
attributeValue {
id
}
attribute {
id
name
}
translation(languageCode: $language) {
id
name
plainText
richText
language {
code
language
}
}
}
`;

export const categoryTranslationFragment = gql`
fragment CategoryTranslation on CategoryTranslatableContent {
translation(languageCode: $language) {
Expand Down Expand Up @@ -64,21 +90,7 @@ export const productTranslationFragment = gql`
}
}
attributeValues {
id
name
richText
attributeValue {
id
}
translation(languageCode: $language) {
id
name
richText
language {
code
language
}
}
...AttributeValueTranslatable
}
}
`;
Expand All @@ -98,21 +110,7 @@ export const productVariantTranslationFragment = gql`
}
}
attributeValues {
id
name
richText
attributeValue {
id
}
translation(languageCode: $language) {
id
name
richText
language {
code
language
}
}
...AttributeValueTranslatable
}
}
`;
Expand Down Expand Up @@ -191,21 +189,7 @@ export const pageTranslationFragment = gql`
}
}
attributeValues {
id
name
richText
attributeValue {
id
}
translation(languageCode: $language) {
id
name
richText
language {
code
language
}
}
...AttributeValueTranslatable
}
}
`;
Expand Down Expand Up @@ -240,11 +224,13 @@ export const attributeChoicesTranslationFragment = gql`
node {
id
name
plainText
richText
inputType
translation(languageCode: $language) {
id
name
plainText
richText
}
}
Expand Down Expand Up @@ -291,28 +277,6 @@ export const attributeTranslationDetailsFragment = gql`
}
`;

export const attributeValueTranslatableContentFragment = gql`
fragment AttributeValueTranslatableContent on AttributeTranslatableContent {
translation(languageCode: $language) {
id
name
}
attribute {
id
name
inputType
choices(
first: $firstValues
after: $afterValues
last: $lastValues
before: $beforeValues
) {
...AttributeChoicesTranslation
}
}
}
`;

export const menuItemTranslationFragment = gql`
fragment MenuItemTranslation on MenuItemTranslatableContent {
translation(languageCode: $language) {
Expand Down
102 changes: 33 additions & 69 deletions src/graphql/hooks.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2437,6 +2437,31 @@ export const CollectionTranslationFragmentDoc = gql`
}
}
`;
export const AttributeValueTranslatableFragmentDoc = gql`
fragment AttributeValueTranslatable on AttributeValueTranslatableContent {
id
name
plainText
richText
attributeValue {
id
}
attribute {
id
name
}
translation(languageCode: $language) {
id
name
plainText
richText
language {
code
language
}
}
}
`;
export const ProductTranslationFragmentDoc = gql`
fragment ProductTranslation on ProductTranslatableContent {
product {
Expand All @@ -2458,24 +2483,10 @@ export const ProductTranslationFragmentDoc = gql`
}
}
attributeValues {
id
name
richText
attributeValue {
id
}
translation(languageCode: $language) {
id
name
richText
language {
code
language
}
}
...AttributeValueTranslatable
}
}
`;
${AttributeValueTranslatableFragmentDoc}`;
export const ProductVariantTranslationFragmentDoc = gql`
fragment ProductVariantTranslation on ProductVariantTranslatableContent {
productVariant {
Expand All @@ -2491,24 +2502,10 @@ export const ProductVariantTranslationFragmentDoc = gql`
}
}
attributeValues {
id
name
richText
attributeValue {
id
}
translation(languageCode: $language) {
id
name
richText
language {
code
language
}
}
...AttributeValueTranslatable
}
}
`;
${AttributeValueTranslatableFragmentDoc}`;
export const SaleTranslationFragmentDoc = gql`
fragment SaleTranslation on SaleTranslatableContent {
sale {
Expand Down Expand Up @@ -2582,24 +2579,10 @@ export const PageTranslationFragmentDoc = gql`
}
}
attributeValues {
id
name
richText
attributeValue {
id
}
translation(languageCode: $language) {
id
name
richText
language {
code
language
}
}
...AttributeValueTranslatable
}
}
`;
${AttributeValueTranslatableFragmentDoc}`;
export const PageTranslatableFragmentDoc = gql`
fragment PageTranslatable on PageTranslatableContent {
id
Expand Down Expand Up @@ -2645,11 +2628,13 @@ export const AttributeChoicesTranslationFragmentDoc = gql`
node {
id
name
plainText
richText
inputType
translation(languageCode: $language) {
id
name
plainText
richText
}
}
Expand Down Expand Up @@ -2678,27 +2663,6 @@ export const AttributeTranslationDetailsFragmentDoc = gql`
}
}
${AttributeChoicesTranslationFragmentDoc}`;
export const AttributeValueTranslatableContentFragmentDoc = gql`
fragment AttributeValueTranslatableContent on AttributeTranslatableContent {
translation(languageCode: $language) {
id
name
}
attribute {
id
name
inputType
choices(
first: $firstValues
after: $afterValues
last: $lastValues
before: $beforeValues
) {
...AttributeChoicesTranslation
}
}
}
${AttributeChoicesTranslationFragmentDoc}`;
export const MenuItemTranslationFragmentDoc = gql`
fragment MenuItemTranslation on MenuItemTranslatableContent {
translation(languageCode: $language) {
Expand Down
3 changes: 2 additions & 1 deletion src/graphql/typePolicies.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,13 +549,14 @@ export type AttributeValueDeletedFieldPolicy = {
recipient?: FieldPolicy<any> | FieldReadFunction<any>,
attributeValue?: FieldPolicy<any> | FieldReadFunction<any>
};
export type AttributeValueTranslatableContentKeySpecifier = ('id' | 'name' | 'richText' | 'plainText' | 'translation' | 'attributeValue' | AttributeValueTranslatableContentKeySpecifier)[];
export type AttributeValueTranslatableContentKeySpecifier = ('id' | 'name' | 'richText' | 'plainText' | 'translation' | 'attribute' | 'attributeValue' | AttributeValueTranslatableContentKeySpecifier)[];
export type AttributeValueTranslatableContentFieldPolicy = {
id?: FieldPolicy<any> | FieldReadFunction<any>,
name?: FieldPolicy<any> | FieldReadFunction<any>,
richText?: FieldPolicy<any> | FieldReadFunction<any>,
plainText?: FieldPolicy<any> | FieldReadFunction<any>,
translation?: FieldPolicy<any> | FieldReadFunction<any>,
attribute?: FieldPolicy<any> | FieldReadFunction<any>,
attributeValue?: FieldPolicy<any> | FieldReadFunction<any>
};
export type AttributeValueTranslateKeySpecifier = ('translationErrors' | 'errors' | 'attributeValue' | AttributeValueTranslateKeySpecifier)[];
Expand Down
Loading

0 comments on commit 7963836

Please sign in to comment.