Major refactor
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { IResolverObject } from 'graphql-tools';
|
||||
import { CategoryAPI } from '../datasources/category-api';
|
||||
import { ProductAPI } from '../datasources/product-api';
|
||||
|
||||
const Category: IResolverObject = {
|
||||
async products({ id }, _args, { dataSources }) {
|
||||
return (<ProductAPI>dataSources.productApi).getCategoryProducts(id);
|
||||
},
|
||||
};
|
||||
|
||||
async function getCategories(_, _args, { dataSources }) {
|
||||
return (<CategoryAPI>dataSources.categoryApi).getCategories();
|
||||
}
|
||||
|
||||
async function getCategory(_, { id }, { dataSources }) {
|
||||
return (<CategoryAPI>dataSources.categoryApi).getCategoryById(id);
|
||||
}
|
||||
|
||||
export const categoryTypeDefs = { Category };
|
||||
|
||||
export const categoryQueryTypeDefs = {
|
||||
categories: getCategories,
|
||||
category: getCategory,
|
||||
};
|
||||
Reference in New Issue
Block a user