P5 7617 cleanup market and locale (#10)

* Minor fixes

* Cleanup with adding Locale type

* Add locales to test
This commit is contained in:
Niklas Fondberg
2021-08-12 10:51:02 +02:00
committed by GitHub
parent 7047fe9851
commit 58ed7fbf6a
10 changed files with 115 additions and 44 deletions
+4 -1
View File
@@ -7,7 +7,10 @@ import {
import { designerQueryTypeDefs, designerTypeDefs } from './designers-resolver';
import { categoryQueryTypeDefs, categoryTypeDefs } from './categories-resolver';
import { keywordsQueryTypeDefs, keywordTypeDefs } from './keywords-resolver';
import { marketsQueryTypeDefs, marketTypeDefs } from './markets-resolver';
import {
marketsQueryTypeDefs,
marketTypeDefs,
} from './markets-locale-resolver';
import { DateTimeResolver, DateResolver, JSONResolver } from 'graphql-scalars';
import { interiorsQueryTypeDefs, interiorTypeDefs } from './interiors-resolver';
+31
View File
@@ -0,0 +1,31 @@
import { IResolverObject } from 'graphql-tools';
import { MarketLocaleAPI } from '../datasources/market-locale-api';
const Market: IResolverObject = {};
async function getMarkets(_, _args, { dataSources }) {
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarkets();
}
async function getMarket(_, { name }, { dataSources }) {
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketByName(name);
}
const Locale: IResolverObject = {};
async function getLocales(_, _args, { dataSources }) {
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocales();
}
async function getLocale(_, { value }, { dataSources }) {
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocaleByValue(value);
}
export const marketTypeDefs = { Market, Locale };
export const marketsQueryTypeDefs = {
markets: getMarkets,
market: getMarket,
locales: getLocales,
locale: getLocale,
};
-19
View File
@@ -1,19 +0,0 @@
import { IResolverObject } from 'graphql-tools';
import { MarketAPI } from '../datasources/market-api';
const Market: IResolverObject = {};
async function getMarkets(_, _args, { dataSources }) {
return (<MarketAPI>dataSources.marketApi).getMarkets();
}
async function getMarket(_, { name }, { dataSources }) {
return (<MarketAPI>dataSources.marketApi).getMarketByName(name);
}
export const marketTypeDefs = { Market };
export const marketsQueryTypeDefs = {
markets: getMarkets,
market: getMarket,
};
+9 -2
View File
@@ -1,5 +1,5 @@
import { IResolverObject } from 'graphql-tools';
import { MarketAPI } from '../datasources/market-api';
import { MarketLocaleAPI } from '../datasources/market-locale-api';
import { OrderAPI } from '../datasources/order-api';
import { FilterInput } from '../types/types';
@@ -15,7 +15,14 @@ const Order: IResolverObject = {
return (<OrderAPI>dataSources.orderApi).getOrderRowsByOrderId(id);
},
async market({ market }, _args, { dataSources }) {
return (<MarketAPI>dataSources.marketApi).getMarketByName(market);
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketByName(
market,
);
},
async locale({ locale }, _args, { dataSources }) {
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getLocaleByValue(
locale,
);
},
};
+4 -2
View File
@@ -5,12 +5,14 @@ import { CategoryAPI } from '../datasources/category-api';
import { Category } from '../types/category-types';
import { KeywordAPI } from '../datasources/keyword-api';
import { Keyword } from '../types/keyword-types';
import { MarketAPI } from '../datasources/market-api';
import { MarketLocaleAPI } from '../datasources/market-locale-api';
import { InteriorAPI } from '../datasources/interior-api';
const ProductBlacklist: IResolverObject = {
async market(parent, _args, { dataSources }) {
return (<MarketAPI>dataSources.marketApi).getMarketById(parent.marketId);
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketById(
parent.marketId,
);
},
};