Address embryo
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user