4257 - add multi locale support to categories resolver (#161)
This commit is contained in:
@@ -125,13 +125,13 @@ WHERE product_category.product_id = ?
|
|||||||
|
|
||||||
async getLocaleDataForId(
|
async getLocaleDataForId(
|
||||||
id: number,
|
id: number,
|
||||||
locale?: string,
|
locales?: string[],
|
||||||
): Promise<CategoryLocaleData[]> {
|
): Promise<CategoryLocaleData[]> {
|
||||||
// Dataloaders does not need scopes validation since they
|
// Dataloaders does not need scopes validation since they
|
||||||
// use other functions.
|
// use other functions.
|
||||||
const res = await this.localeDataLoader.load(id);
|
const res = await this.localeDataLoader.load(id);
|
||||||
if (locale) {
|
if (locales) {
|
||||||
return res.filter((row) => row.locale === locale);
|
return res.filter((row) => locales.includes(row.locale));
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ const Category = {
|
|||||||
async localeNames({ id }, _, { dataSources }) {
|
async localeNames({ id }, _, { dataSources }) {
|
||||||
return (<CategoryAPI>dataSources.categoryApi).getLocaleNameForId(id);
|
return (<CategoryAPI>dataSources.categoryApi).getLocaleNameForId(id);
|
||||||
},
|
},
|
||||||
async localeData({ id }, input: { locale: string }, { dataSources }) {
|
async localeData({ id }, input: { locales: string[] }, { dataSources }) {
|
||||||
return (<CategoryAPI>dataSources.categoryApi).getLocaleDataForId(
|
return (<CategoryAPI>dataSources.categoryApi).getLocaleDataForId(
|
||||||
id,
|
id,
|
||||||
input.locale,
|
input.locales,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -230,7 +230,7 @@ type Category {
|
|||||||
"""
|
"""
|
||||||
products(includeAllSubCategories: Boolean): [Product]
|
products(includeAllSubCategories: Boolean): [Product]
|
||||||
localeNames: JSON
|
localeNames: JSON
|
||||||
localeData(locale: String): [CategoryLocaleData]!
|
localeData(locales: [String]!): [CategoryLocaleData]!
|
||||||
}
|
}
|
||||||
|
|
||||||
type Batch {
|
type Batch {
|
||||||
|
|||||||
Reference in New Issue
Block a user