| Current Path : /proc/thread-self/root/home/deltalab/PMS/sms-connector/graphql/schemas/ |
| Current File : //proc/thread-self/root/home/deltalab/PMS/sms-connector/graphql/schemas/shipment.schema.js |
const { adapter } = require('../../adapters/shippypro-adapter');
const { shipmentInfoInputType } = require('../types/shipment.type');
const { shipmentCreationTC } = require('../types/shipment.type');
const { shipmentStatusTC } = require('../types/shipment.type');
const { shipmentTC } = require('../types/shipment.type');
/**
* Get a shipment status based on the given shipmentId
*/
shipmentStatusTC.addResolver({
kind: 'query',
name: 'shipmentStatus',
type: shipmentStatusTC,
args: {
shipmentId: 'String!'
},
resolve: ({ args }) => {
console.log(`getting shipment status for shipment id ${args.shipmentId}`);
return adapter.getShipmentStatusAsync(args.shipmentId);
}
});
/**
* Create a shipment using the given shipment data
*/
shipmentTC.addResolver({
kind: 'mutation',
name: 'createShipment',
type: shipmentCreationTC,
args: {
shipmentData: shipmentInfoInputType
},
resolve: ({ args }) => {
console.log(`creating shipment for order ${args.shipmentData.orderId}`);
return adapter.createShipmentAsync(args.shipmentData);
}
});
// QUERIES ===============================
const shipmentQueries = {
shipmentStatus: shipmentStatusTC.getResolver('shipmentStatus'),
};
// MUTATIONS =============================
const shipmentMutations = {
createShipment: shipmentTC.getResolver('createShipment'),
};
// EXPORTS ==================================================
module.exports = {
shipmentQueries,
shipmentMutations,
};