1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-29 05:10:05 +02:00

Update graphi and map resolvers

This commit is contained in:
geek 2017-05-23 21:32:22 -05:00 committed by Sérgio Ramos
parent ba5ccea851
commit 2e3a436594
2 changed files with 68 additions and 22 deletions

View File

@ -10,34 +10,80 @@ const internals = {
exports.options = (data) => {
const getPortal = function (args, request) {
const queryWrap = function (name) {
return function (args, request) {
return data[name](args);
};
};
const getDeploymentGroups = function (args, request) {
const queries = [
'portal',
'deploymentGroups',
'deploymentGroup',
'services',
'service',
'instances',
'instance',
'metricTypes',
'metricData',
'package',
'datacenters',
'instanceMetric'
];
const resolvers = {
createDeploymentGroup: (args, request) => {
return data.createDeploymentGroup(args.name);
},
updateDeploymentGroup: (args, request) => {
return data.updateDeploymentGroup(args.uuid, args.name);
},
provisionManifest: (args, request) => {
return data.provisionManifest(args.deploymentGroupUuid, args.type, args.format, args.raw);
},
scale: (args, request) => {
return data.scale(args.service, args.replicas);
},
stopServices: (args, request) => {
return data.stopServices(args.uuids);
},
startServices: (args, request) => {
return data.startServices(args.uuids);
},
restartServices: (args, request) => {
return data.restartServices(args.uuids);
},
deleteServices: (args, request) => {
return data.deleteServices(args.uuids);
},
stopInstances: (args, request) => {
return data.stopInstances(args.uuids);
},
startInstances: (args, request) => {
return data.startInstances(args.uuids);
},
restartInstances: (args, request) => {
return data.restartInstances(args.uuids);
}
};
const getDeploymentGroup = function (args, request) {
};
const getServiceScales = function (args, request) {
};
const getServiceScale = function (args, request) {
};
queries.forEach((query) => {
const functionName = 'get' + query[0].toUpperCase() + query.slice(1);
resolvers[query] = queryWrap(functionName);
});
return {
schema: internals.schema,
functions: {
portal: getPortal,
deploymentGroups: getDeploymentGroups,
deploymentGroup: getDeploymentGroup,
serviceScales: getServiceScales,
serviceScale: getServiceScale
}
resolvers
};
};

View File

@ -24,7 +24,7 @@
},
"dependencies": {
"boom": "^4.3.1",
"graphi": "^1.0.0",
"graphi": "^2.0.0",
"hoek": "^4.1.1",
"joi": "^10.4.1",
"portal-data": "^1.0.0"