3384 - add locales to market query (#147)
This commit is contained in:
@@ -73,6 +73,25 @@ export class MarketLocaleAPI extends SQLDataSource {
|
||||
);
|
||||
}
|
||||
|
||||
async getLocalesForMarketId(marketId: number): Promise<Locale> {
|
||||
ScopeAccess.validate(this.user).all([Scopes.LOCALES_READ]);
|
||||
return (
|
||||
this.knex
|
||||
.select(
|
||||
'market_id',
|
||||
'locales.id',
|
||||
'value',
|
||||
'fallback_id',
|
||||
'locales.name',
|
||||
)
|
||||
.from('market_locales')
|
||||
.leftJoin('locales', 'locales.id', 'market_locales.locale_id')
|
||||
.where('market_id', marketId)
|
||||
// @ts-ignore
|
||||
.cache(MINUTE * 5)
|
||||
);
|
||||
}
|
||||
|
||||
async getLocaleByValue(value: string): Promise<Locale> {
|
||||
ScopeAccess.validate(this.user).all([Scopes.LOCALES_READ]);
|
||||
return (
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||
|
||||
const Market = {};
|
||||
const Market = {
|
||||
async locales({ id }, _args, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocalesForMarketId(
|
||||
id,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
async function getMarkets(_, _args, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarkets();
|
||||
|
||||
@@ -127,6 +127,7 @@ type Market {
|
||||
vat: Float!
|
||||
currency: String!
|
||||
priceAdjustment: Float!
|
||||
locales: [Locale]!
|
||||
}
|
||||
|
||||
type Locale {
|
||||
|
||||
Reference in New Issue
Block a user