Added product admin features
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { Api2DataSource } from '../datasources/api2-datasource';
|
||||
import { OrderAPI } from '../datasources/order-api';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
import { Product } from '../types/product-types';
|
||||
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 { InteriorAPI } from '../datasources/interior-api';
|
||||
|
||||
const ProductBlacklist: IResolverObject = {
|
||||
async market(parent, _args, { dataSources }) {
|
||||
return (<OrderAPI>dataSources.orderApi).getMarketById(parent.marketId);
|
||||
return (<MarketAPI>dataSources.marketApi).getMarketById(parent.marketId);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -20,24 +20,22 @@ const Product: IResolverObject = {
|
||||
return (<CategoryAPI>dataSources.categoryApi).getProductCategories(id);
|
||||
},
|
||||
async designer({ designerId }, args, { dataSources }) {
|
||||
if (!designerId) {
|
||||
return null;
|
||||
}
|
||||
return dataSources.designerApi.getDesignerById(designerId);
|
||||
},
|
||||
async keywords({ id }, _args, { dataSources }): Promise<Array<Keyword>> {
|
||||
return (<KeywordAPI>dataSources.keywordApi).getProductKeywords(id);
|
||||
},
|
||||
async api1json({ id }, _args, { dataSources }): Promise<JSON> {
|
||||
return dataSources.api1.getProduct(id);
|
||||
async related({ id }, _args, { dataSources }) {
|
||||
return (<ProductAPI>dataSources.productApi).getRelatedProducts(id);
|
||||
},
|
||||
};
|
||||
|
||||
const PrintProduct: IResolverObject = {
|
||||
async price({ id }, { market, width, height, sku }, { dataSources }) {
|
||||
return (<Api2DataSource>dataSources.api2).getPrice(
|
||||
market,
|
||||
width,
|
||||
height,
|
||||
sku,
|
||||
);
|
||||
async interiors({ id }, _args, { dataSources }) {
|
||||
return (<InteriorAPI>dataSources.interiorApi).getPrintProductInteriors(id);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -67,3 +65,11 @@ export const productQueryTypeDefs = {
|
||||
products: getProducts,
|
||||
product: getProduct,
|
||||
};
|
||||
|
||||
// Mutations below
|
||||
|
||||
export const productMutationTypeDefs = {
|
||||
addKeyword(_, { productId, keywordId }, { dataSources }) {
|
||||
return { result: 'OK' };
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user