Product info mutation (#14)
* Add mutation for product info * Upgrade to apollo 3
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
import {
|
||||
Product,
|
||||
@@ -12,7 +11,7 @@ import { Keyword } from '../types/keyword-types';
|
||||
import { MarketLocaleAPI } from '../datasources/market-locale-api';
|
||||
import { InteriorAPI } from '../datasources/interior-api';
|
||||
|
||||
const ProductBlacklist: IResolverObject = {
|
||||
const ProductBlacklist = {
|
||||
async market(parent, _args, { dataSources }) {
|
||||
return (<MarketLocaleAPI>dataSources.marketLocaleApi).getMarketById(
|
||||
parent.marketId,
|
||||
@@ -20,7 +19,7 @@ const ProductBlacklist: IResolverObject = {
|
||||
},
|
||||
};
|
||||
|
||||
const Product: IResolverObject = {
|
||||
const Product = {
|
||||
// (parent, args, ctx, info)
|
||||
async categories({ id }, _args, { dataSources }): Promise<Array<Category>> {
|
||||
return (<CategoryAPI>dataSources.categoryApi).getProductCategories(id);
|
||||
@@ -39,7 +38,7 @@ const Product: IResolverObject = {
|
||||
},
|
||||
};
|
||||
|
||||
const PrintProduct: IResolverObject = {
|
||||
const PrintProduct = {
|
||||
async interiors({ id }, _args, { dataSources }) {
|
||||
return (<InteriorAPI>dataSources.interiorApi).getPrintProductInteriors(id);
|
||||
},
|
||||
@@ -78,10 +77,14 @@ export const productQueryTypeDefs = {
|
||||
product: getProduct,
|
||||
};
|
||||
|
||||
// Mutations below, embryo stage
|
||||
|
||||
///////////////////
|
||||
// Mutations below
|
||||
export const productMutationTypeDefs = {
|
||||
addKeyword(_, { productId, keywordId }, { dataSources }) {
|
||||
return { result: 'OK' };
|
||||
async productInfo(_, { productId, info }, { dataSources }) {
|
||||
await (<ProductAPI>dataSources.productApi).updateProductInfo(
|
||||
productId,
|
||||
info,
|
||||
);
|
||||
return (<ProductAPI>dataSources.productApi).getProduct(productId);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user