Address embryo

This commit is contained in:
Niklas Fondberg
2021-04-07 18:30:56 +02:00
parent 1b304930d3
commit f3f39b2097
5 changed files with 266 additions and 19 deletions
+2 -1
View File
@@ -1,10 +1,11 @@
import orders from './orders-resolver';
import orders, { ContactInformation } from './orders-resolver';
import products from './products-resolver';
import { DateTimeScalar } from './datetime-type';
const resolvers = {
Query: { ...orders, ...products },
DateTime: DateTimeScalar,
ContactInformation,
};
export default resolvers;
+19 -3
View File
@@ -1,7 +1,23 @@
// (parent, args, ctx, info)
import { IResolverObject } from 'graphql-tools';
export const ContactInformation: IResolverObject = {
// (parent, args, ctx, info)
async address({ addressId }, args, { dataSources }) {
return dataSources.orderApi.getAddress(addressId);
},
};
async function getOrders(_, __, { dataSources }) {
return dataSources.orderApi.getOrders();
}
async function getOrder(_, { id }, { dataSources }) {
return dataSources.orderApi.getOrder(id);
}
const orders = {
orders: (_, __, { dataSources }) => dataSources.orderApi.getOrders(),
order: (_, { id }, { dataSources }) => dataSources.orderApi.getOrder(id),
orders: getOrders,
order: () => getOrder,
};
export default orders;