Added orderrows

This commit is contained in:
Niklas Fondberg
2021-04-08 13:20:43 +02:00
parent f3f39b2097
commit e0f629d54d
8 changed files with 295 additions and 89 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
import orders, { ContactInformation } from './orders-resolver';
import orders, { ContactInformation, Order } from './orders-resolver';
import products from './products-resolver';
import { DateTimeScalar } from './datetime-type';
@@ -6,6 +6,7 @@ const resolvers = {
Query: { ...orders, ...products },
DateTime: DateTimeScalar,
ContactInformation,
Order,
};
export default resolvers;
+7 -1
View File
@@ -7,6 +7,12 @@ export const ContactInformation: IResolverObject = {
},
};
export const Order: IResolverObject = {
async rows({ id }, args, { dataSources }) {
return dataSources.orderApi.getOrderRows(id);
},
};
async function getOrders(_, __, { dataSources }) {
return dataSources.orderApi.getOrders();
}
@@ -17,7 +23,7 @@ async function getOrder(_, { id }, { dataSources }) {
const orders = {
orders: getOrders,
order: () => getOrder,
order: getOrder,
};
export default orders;