* refactor: config() from mutation to query * refactor(cp-frontend): remove unused dependency * feat(portal-watch): expose getContainers() and compose tags * fix(portal-watch): assert services by name AND hash * feat(portal-data): expose importable and import APIs * fix(portal-data): add missing dependencies * feat(portal-api): expose import/importable * feat(cp-gql-schema): add import/importable * feat(cp-frontend): import existing project * style(portal-watch): lint * style(portal-data): lint * chore: update lockfile
61 lines
1.2 KiB
JavaScript
61 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
module.exports = (data) => {
|
|
const queryWrap = function (name) {
|
|
return function (options, request, cb) {
|
|
return data[name](options, cb);
|
|
};
|
|
};
|
|
|
|
const mutationWrap = function (name) {
|
|
return function (options, request, cb) {
|
|
return data[name](options, cb);
|
|
};
|
|
};
|
|
|
|
const queries = [
|
|
'portal',
|
|
'deploymentGroups',
|
|
'deploymentGroup',
|
|
'services',
|
|
'service',
|
|
'instances',
|
|
'instance',
|
|
'metricTypes',
|
|
'metricData',
|
|
'package',
|
|
'datacenters',
|
|
'instanceMetric',
|
|
'config',
|
|
'importableDeploymentGroups'
|
|
];
|
|
|
|
const mutations = [
|
|
'createDeploymentGroup',
|
|
'updateDeploymentGroup',
|
|
'provisionManifest',
|
|
'scale',
|
|
'stopServices',
|
|
'startServices',
|
|
'restartServices',
|
|
'deleteServices',
|
|
'stopInstances',
|
|
'startInstances',
|
|
'restartInstances',
|
|
'importDeploymentGroup'
|
|
];
|
|
|
|
const resolvers = {};
|
|
|
|
queries.forEach((query) => {
|
|
const functionName = 'get' + query[0].toUpperCase() + query.slice(1);
|
|
resolvers[query] = queryWrap(functionName);
|
|
});
|
|
|
|
mutations.forEach((mutation) => {
|
|
resolvers[mutation] = mutationWrap(mutation);
|
|
});
|
|
|
|
return resolvers;
|
|
};
|