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(
|
||||
id: number,
|
||||
locale?: string,
|
||||
locales?: string[],
|
||||
): Promise<CategoryLocaleData[]> {
|
||||
// Dataloaders does not need scopes validation since they
|
||||
// use other functions.
|
||||
const res = await this.localeDataLoader.load(id);
|
||||
if (locale) {
|
||||
return res.filter((row) => row.locale === locale);
|
||||
if (locales) {
|
||||
return res.filter((row) => locales.includes(row.locale));
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -14,10 +14,10 @@ const Category = {
|
||||
async localeNames({ id }, _, { dataSources }) {
|
||||
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(
|
||||
id,
|
||||
input.locale,
|
||||
input.locales,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ type Category {
|
||||
"""
|
||||
products(includeAllSubCategories: Boolean): [Product]
|
||||
localeNames: JSON
|
||||
localeData(locale: String): [CategoryLocaleData]!
|
||||
localeData(locales: [String]!): [CategoryLocaleData]!
|
||||
}
|
||||
|
||||
type Batch {
|
||||
|
||||
Reference in New Issue
Block a user