Skip to content

Commit

Permalink
use handle instead of key for translating
Browse files Browse the repository at this point in the history
  • Loading branch information
jamalsoueidan committed Jun 13, 2024
1 parent e7b75bb commit 691af21
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
4 changes: 1 addition & 3 deletions app/graphql/fragments/Translation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
export const TRANSLATIONS_FRAGMENT = `#graphql
fragment Translations on Metaobject {
key: field(key: "key") {
value
}
handle
value: field(key: "value") {
value
}
Expand Down
2 changes: 1 addition & 1 deletion app/providers/Translation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const convertJsonStructure = (data?: TranslationsFragment[] | null) => {
const result: Record<string, string> = {};

data?.forEach((node) => {
const key = node.key?.value;
const key = node.handle;
const value = node.value?.value;
if (key && value) {
result[key] = value;
Expand Down
33 changes: 16 additions & 17 deletions storefrontapi.generated.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,7 @@ export type LocationFragment = Pick<
>;
};

export type TranslationsFragment = {
key?: StorefrontAPI.Maybe<Pick<StorefrontAPI.MetaobjectField, 'value'>>;
export type TranslationsFragment = Pick<StorefrontAPI.Metaobject, 'handle'> & {
value?: StorefrontAPI.Maybe<Pick<StorefrontAPI.MetaobjectField, 'value'>>;
};

Expand Down Expand Up @@ -4506,12 +4505,13 @@ export type PageFragment = Pick<StorefrontAPI.Page, 'id' | 'title' | 'body'> & {
}>;
translations?: StorefrontAPI.Maybe<{
references?: StorefrontAPI.Maybe<{
nodes: Array<{
key?: StorefrontAPI.Maybe<Pick<StorefrontAPI.MetaobjectField, 'value'>>;
value?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.MetaobjectField, 'value'>
>;
}>;
nodes: Array<
Pick<StorefrontAPI.Metaobject, 'handle'> & {
value?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.MetaobjectField, 'value'>
>;
}
>;
}>;
}>;
options?: StorefrontAPI.Maybe<{
Expand Down Expand Up @@ -5170,14 +5170,13 @@ export type PageQuery = {
}>;
translations?: StorefrontAPI.Maybe<{
references?: StorefrontAPI.Maybe<{
nodes: Array<{
key?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.MetaobjectField, 'value'>
>;
value?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.MetaobjectField, 'value'>
>;
}>;
nodes: Array<
Pick<StorefrontAPI.Metaobject, 'handle'> & {
value?: StorefrontAPI.Maybe<
Pick<StorefrontAPI.MetaobjectField, 'value'>
>;
}
>;
}>;
}>;
options?: StorefrontAPI.Maybe<{
Expand Down Expand Up @@ -6065,7 +6064,7 @@ interface GeneratedQueryTypes {
return: StoreCollectionsQuery;
variables: StoreCollectionsQueryVariables;
};
'#graphql\n #graphql\n #tags\n #graphql\n fragment Image on MediaImage {\n id\n image {\n url\n height\n width\n }\n }\n\n #graphql\n fragment BackgroundImage on Metaobject {\n id\n type\n image: field(key: "image") {\n reference {\n ...Image\n }\n }\n opacity: field(key:"opacity") {\n value\n }\n style: field(key:"style") {\n value\n }\n }\n\n #graphql\n fragment Button on Metaobject {\n id\n type\n text: field(key: "text") {\n value\n }\n linkTo: field(key:"link_to") {\n value\n }\n variant: field(key:"variant") {\n value\n }\n color: field(key:"color") {\n value\n }\n }\n\n #graphql\n fragment Overlay on Metaobject {\n id\n type\n color: field(key: "color") {\n value\n }\n opacity: field(key:"opacity") {\n value\n type\n }\n }\n\n\n #fragments\n #graphql\n #graphql\n fragment AccordionItem on Metaobject {\n id\n type\n label: field(key: "label") {\n value\n }\n text: field(key:"text") {\n value\n }\n }\n\n fragment Accordion on Metaobject {\n id\n type\n name: field(key: "name") {\n value\n }\n variant: field(key:"variant") {\n key\n value\n }\n items: field(key:"items") {\n references(first: 10) {\n nodes {\n ...AccordionItem\n }\n }\n }\n }\n\n #graphql\n fragment CallToAction on Metaobject {\n id\n type\n name: field(key:"name") {\n value\n }\n title: field(key:"title") {\n value\n }\n image: field(key: "image") {\n reference {\n ...Image\n }\n }\n color: field(key: "color") {\n value\n }\n button: field(key:"button") {\n reference {\n ...Button\n }\n }\n overlay: field(key: "overlay") {\n reference {\n ...Overlay\n }\n }\n }\n\n #graphql\n fragment CardMedia on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description: field(key:"description") {\n value\n }\n image: field(key: "image") {\n reference {\n ...Image\n }\n }\n flip: field(key:"flip") {\n value\n }\n }\n\n #graphql\n #graphql\n fragment FeatureItem on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description: field(key: "description") {\n value\n }\n icon: field(key: "icon") {\n value\n }\n }\n\n\n fragment Features on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n subtitle: field(key: "subtitle") {\n value\n }\n items: field(key: "items") {\n references(first: 10) {\n nodes {\n ...FeatureItem\n }\n }\n }\n }\n\n #graphql\n #graphql\n #graphql\n fragment ThemeIcon on Metaobject {\n id\n type\n name: field(key: "name") {\n value\n }\n icon: field(key: "icon") {\n value\n }\n variant: field(key: "variant") {\n value\n }\n color: field(key: "color") {\n value\n }\n radius: field(key: "radius") {\n value\n }\n }\n\n\n fragment HelpItem on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description: field(key: "description") {\n value\n }\n themeIcon: field(key: "theme_icon") {\n reference {\n ...ThemeIcon\n }\n }\n backgroundColor: field(key: "background_color") {\n value\n }\n }\n\n\n fragment Help on Metaobject {\n id\n type\n name: field(key: "name") {\n value\n }\n title: field(key: "title") {\n value\n }\n items: field(key: "items") {\n references(first: 10) {\n nodes {\n ...HelpItem\n }\n }\n }\n backgroundColor: field(key: "background_color") {\n value\n }\n }\n\n #graphql\n fragment Maps on Metaobject {\n id\n type\n url: field(key: "url") {\n value\n }\n }\n\n #graphql\n fragment SideBySide on Metaobject {\n id\n type\n title: field(key:"title") {\n value\n }\n text: field(key: "text") {\n value\n }\n }\n\n #graphql\n fragment VisualTeaser on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n subtitle: field(key: "subtitle") {\n value\n }\n height:field(key:"height") {\n value\n }\n backgroundColor:field(key:"background_color") {\n value\n }\n fontColor: field(key:"font_color") {\n value\n }\n justify: field(key:"justify") {\n value\n }\n backgroundImage: field(key:"background_image") {\n reference {\n ...BackgroundImage\n }\n }\n subbutton: field(key:"subbutton") {\n reference {\n ...Button\n }\n }\n }\n\n #graphql\n fragment Faq on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description:field(key:"description") {\n value\n }\n backgroundColor:field(key:"background_color") {\n value\n }\n direction: field(key:"direction") {\n value\n }\n accordion: field(key: "accordion") {\n reference {\n ...Accordion\n }\n }\n }\n\n #graphql\n #graphql\n fragment ImageGridWithHeaderCollection on Collection {\n id\n title\n handle\n image {\n height\n width\n url(transform: {maxHeight: 150, maxWidth: 150, crop: CENTER})\n }\n }\n\n fragment ImageGridWithHeader on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n backgroundColor:field(key:"background_color") {\n value\n }\n collections: field(key:"collections") {\n references(first: 5) {\n nodes {\n ...ImageGridWithHeaderCollection\n }\n }\n }\n }\n\n\n #graphql\n fragment Translations on Metaobject {\n key: field(key: "key") {\n value\n }\n value: field(key: "value") {\n value\n }\n }\n\n\n fragment Page on Page {\n id\n title\n body\n seo {\n description\n title\n }\n components: metafield(namespace: "custom", key: "components") {\n references(first: 10) {\n nodes {\n ...Accordion\n ...CallToAction\n ...CardMedia\n ...Features\n ...Help\n ...Maps\n ...SideBySide\n ...VisualTeaser\n ...Faq\n ...ImageGridWithHeader\n }\n }\n }\n\n header: metafield(namespace: "booking", key: "header") {\n reference {\n ...Accordion\n ...CallToAction\n ...CardMedia\n ...Features\n ...Help\n ...Maps\n ...SideBySide\n ...VisualTeaser\n ...Faq\n ...ImageGridWithHeader\n }\n }\n\n translations: metafield(namespace: "booking", key: "translations") {\n references(first: 250) {\n nodes {\n ...Translations\n }\n }\n }\n\n options: metafield(namespace: "custom", key: "options") {\n references(first: 10) {\n nodes {\n ...Accordion\n ...CallToAction\n ...CardMedia\n ...Features\n ...Help\n ...Maps\n ...SideBySide\n ...VisualTeaser\n ...Faq\n ...ImageGridWithHeader\n }\n }\n }\n }\n\n query Page(\n $language: LanguageCode,\n $country: CountryCode,\n $handle: String!\n )\n @inContext(language: $language, country: $country) {\n page(handle: $handle) {\n ...Page\n }\n }\n': {
'#graphql\n #graphql\n #tags\n #graphql\n fragment Image on MediaImage {\n id\n image {\n url\n height\n width\n }\n }\n\n #graphql\n fragment BackgroundImage on Metaobject {\n id\n type\n image: field(key: "image") {\n reference {\n ...Image\n }\n }\n opacity: field(key:"opacity") {\n value\n }\n style: field(key:"style") {\n value\n }\n }\n\n #graphql\n fragment Button on Metaobject {\n id\n type\n text: field(key: "text") {\n value\n }\n linkTo: field(key:"link_to") {\n value\n }\n variant: field(key:"variant") {\n value\n }\n color: field(key:"color") {\n value\n }\n }\n\n #graphql\n fragment Overlay on Metaobject {\n id\n type\n color: field(key: "color") {\n value\n }\n opacity: field(key:"opacity") {\n value\n type\n }\n }\n\n\n #fragments\n #graphql\n #graphql\n fragment AccordionItem on Metaobject {\n id\n type\n label: field(key: "label") {\n value\n }\n text: field(key:"text") {\n value\n }\n }\n\n fragment Accordion on Metaobject {\n id\n type\n name: field(key: "name") {\n value\n }\n variant: field(key:"variant") {\n key\n value\n }\n items: field(key:"items") {\n references(first: 10) {\n nodes {\n ...AccordionItem\n }\n }\n }\n }\n\n #graphql\n fragment CallToAction on Metaobject {\n id\n type\n name: field(key:"name") {\n value\n }\n title: field(key:"title") {\n value\n }\n image: field(key: "image") {\n reference {\n ...Image\n }\n }\n color: field(key: "color") {\n value\n }\n button: field(key:"button") {\n reference {\n ...Button\n }\n }\n overlay: field(key: "overlay") {\n reference {\n ...Overlay\n }\n }\n }\n\n #graphql\n fragment CardMedia on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description: field(key:"description") {\n value\n }\n image: field(key: "image") {\n reference {\n ...Image\n }\n }\n flip: field(key:"flip") {\n value\n }\n }\n\n #graphql\n #graphql\n fragment FeatureItem on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description: field(key: "description") {\n value\n }\n icon: field(key: "icon") {\n value\n }\n }\n\n\n fragment Features on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n subtitle: field(key: "subtitle") {\n value\n }\n items: field(key: "items") {\n references(first: 10) {\n nodes {\n ...FeatureItem\n }\n }\n }\n }\n\n #graphql\n #graphql\n #graphql\n fragment ThemeIcon on Metaobject {\n id\n type\n name: field(key: "name") {\n value\n }\n icon: field(key: "icon") {\n value\n }\n variant: field(key: "variant") {\n value\n }\n color: field(key: "color") {\n value\n }\n radius: field(key: "radius") {\n value\n }\n }\n\n\n fragment HelpItem on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description: field(key: "description") {\n value\n }\n themeIcon: field(key: "theme_icon") {\n reference {\n ...ThemeIcon\n }\n }\n backgroundColor: field(key: "background_color") {\n value\n }\n }\n\n\n fragment Help on Metaobject {\n id\n type\n name: field(key: "name") {\n value\n }\n title: field(key: "title") {\n value\n }\n items: field(key: "items") {\n references(first: 10) {\n nodes {\n ...HelpItem\n }\n }\n }\n backgroundColor: field(key: "background_color") {\n value\n }\n }\n\n #graphql\n fragment Maps on Metaobject {\n id\n type\n url: field(key: "url") {\n value\n }\n }\n\n #graphql\n fragment SideBySide on Metaobject {\n id\n type\n title: field(key:"title") {\n value\n }\n text: field(key: "text") {\n value\n }\n }\n\n #graphql\n fragment VisualTeaser on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n subtitle: field(key: "subtitle") {\n value\n }\n height:field(key:"height") {\n value\n }\n backgroundColor:field(key:"background_color") {\n value\n }\n fontColor: field(key:"font_color") {\n value\n }\n justify: field(key:"justify") {\n value\n }\n backgroundImage: field(key:"background_image") {\n reference {\n ...BackgroundImage\n }\n }\n subbutton: field(key:"subbutton") {\n reference {\n ...Button\n }\n }\n }\n\n #graphql\n fragment Faq on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n description:field(key:"description") {\n value\n }\n backgroundColor:field(key:"background_color") {\n value\n }\n direction: field(key:"direction") {\n value\n }\n accordion: field(key: "accordion") {\n reference {\n ...Accordion\n }\n }\n }\n\n #graphql\n #graphql\n fragment ImageGridWithHeaderCollection on Collection {\n id\n title\n handle\n image {\n height\n width\n url(transform: {maxHeight: 150, maxWidth: 150, crop: CENTER})\n }\n }\n\n fragment ImageGridWithHeader on Metaobject {\n id\n type\n title: field(key: "title") {\n value\n }\n backgroundColor:field(key:"background_color") {\n value\n }\n collections: field(key:"collections") {\n references(first: 5) {\n nodes {\n ...ImageGridWithHeaderCollection\n }\n }\n }\n }\n\n\n #graphql\n fragment Translations on Metaobject {\n handle\n value: field(key: "value") {\n value\n }\n }\n\n\n fragment Page on Page {\n id\n title\n body\n seo {\n description\n title\n }\n components: metafield(namespace: "custom", key: "components") {\n references(first: 10) {\n nodes {\n ...Accordion\n ...CallToAction\n ...CardMedia\n ...Features\n ...Help\n ...Maps\n ...SideBySide\n ...VisualTeaser\n ...Faq\n ...ImageGridWithHeader\n }\n }\n }\n\n header: metafield(namespace: "booking", key: "header") {\n reference {\n ...Accordion\n ...CallToAction\n ...CardMedia\n ...Features\n ...Help\n ...Maps\n ...SideBySide\n ...VisualTeaser\n ...Faq\n ...ImageGridWithHeader\n }\n }\n\n translations: metafield(namespace: "booking", key: "translations") {\n references(first: 250) {\n nodes {\n ...Translations\n }\n }\n }\n\n options: metafield(namespace: "custom", key: "options") {\n references(first: 10) {\n nodes {\n ...Accordion\n ...CallToAction\n ...CardMedia\n ...Features\n ...Help\n ...Maps\n ...SideBySide\n ...VisualTeaser\n ...Faq\n ...ImageGridWithHeader\n }\n }\n }\n }\n\n query Page(\n $language: LanguageCode,\n $country: CountryCode,\n $handle: String!\n )\n @inContext(language: $language, country: $country) {\n page(handle: $handle) {\n ...Page\n }\n }\n': {
return: PageQuery;
variables: PageQueryVariables;
};
Expand Down

0 comments on commit 691af21

Please sign in to comment.