1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 06:00:06 +02:00

Update resolvers accoring to latest schema

This commit is contained in:
JUDIT GRESKOVITS 2017-05-17 17:10:18 +01:00 committed by Sérgio Ramos
parent aa8bdf5eb2
commit 4b2e0f53ae
11 changed files with 107 additions and 78 deletions

View File

@ -1,5 +1,5 @@
fragment DeploymentGroupInfo on DeploymentGroup {
uuid
name
pathName
slug
}

View File

@ -1,8 +1,8 @@
#import "./DeploymentGroupInfo.gql"
#import "./ServiceInfo.gql"
query Instances($deploymentGroupPathName: String!) {
deploymentGroup(pathName: $deploymentGroupPathName) {
query Instances($deploymentGroupSlug: String!) {
deploymentGroup(slug: $deploymentGroupSlug) {
...DeploymentGroupInfo
services {
...ServiceInfo

View File

@ -1,25 +0,0 @@
query Instances($deploymentGroupId: String!){
deploymentGroup(id: $deploymentGroupId) {
uuid
id
name
services {
uuid
id
name
instances {
uuid
name
metrics {
type {
id
}
data {
timestamp
value
}
}
}
}
}
}

View File

@ -1,7 +1,6 @@
query Portal {
portal {
username
host
datacenter {
id
}

View File

@ -1,5 +1,5 @@
fragment ServiceInfo on Service {
uuid
name
pathName
slug
}

View File

@ -1,8 +1,8 @@
#import "./DeploymentGroupInfo.gql"
#import "./ServiceInfo.gql"
query Services($deploymentGroupPathName: String!){
deploymentGroup(pathName: $deploymentGroupPathName) {
query Services($deploymentGroupSlug: String!){
deploymentGroup(slug: $deploymentGroupSlug) {
...DeploymentGroupInfo
services {
...ServiceInfo

View File

@ -1,8 +1,8 @@
#import "./DeploymentGroupInfo.gql"
#import "./ServiceInfo.gql"
query Instances($deploymentGroupPathName: String!){
deploymentGroup(pathName: $deploymentGroupPathName) {
query Instances($deploymentGroupSlug: String!){
deploymentGroup(slug: $deploymentGroupSlug) {
...DeploymentGroupInfo
services {
...ServiceInfo

View File

@ -3,7 +3,7 @@ query SingleMetrics {
type {
uuid
name
id
machineId
}
data {
timestamp

View File

@ -5,11 +5,11 @@ import { normalMetricData, leakMetricData } from './mock-data/metrics';
const datacenters = data.datacenters.data;
const portal = { username: 'juditgreskovits', host: 'dockerhost', datacenter: datacenters[0]};
const deploymentGroups = data.projects.data.map(p => {
p.pathName = p.id;
p.slug = p.id;
return p;
});
const services = data.services.data.map(s => {
s.pathName = s.id;
s.slug = s.id;
return s;
});
const instances = data.instances.data;
@ -28,24 +28,61 @@ const resolveFunctions = {
portal() {
return portal;
},
deploymentGroups() {
deploymentGroups(_, { name, slug }) {
return deploymentGroups;
},
deploymentGroup(_, { uuid, pathName }) {
deploymentGroup(_, { uuid, name, slug }) {
if(uuid) {
return find(deploymentGroups, { uuid: uuid });
}
if(pathName) {
return find(deploymentGroups, { pathName: pathName });
if(slug) {
return find(deploymentGroups, { slug: slug });
}
return null;
},
services(_, { deploymentGroupUuid=null, deploymentGroupPathName=null }) {
serviceScales(_, { serviceName, versionUuid }) { // : [ServiceScale]
return [];
},
serviceScale(_, { uuid }) { // : ServiceScale
return {};
},
convergenceActions(_, { type, service, versionUuid }) { // : [ConvergenceAction]
return [];
},
convergenceAction(uuid) { // : ConvergenceAction
return {};
},
stateConvergencePlans(_, { running, versionUuid }) { // : [StateConvergencePlan]
return [];
},
stateConvergencePlan(_, { uuid }) { // : StateConvergencePlan
return [];
},
versions(_, { manifestUuid, deploymentGroupUuid }) { // : [Version]
return [];
},
version(_, { uuid, manifestUuid }) { // : Version
return null;
},
manifests(_, { type, deploymentGroupUuid }) { // : [Manifest]
return [];
},
manifest(_, { uuid }) { // : Manifest
return null;
},
services(_, { name, slug, parentUuid, deploymentGroupUuid, deploymentGroupSlug }) { // }: [Service]
if(deploymentGroupUuid) {
return filter(services, { project: deploymentGroupUuid });
}
if(deploymentGroupPathName) {
const deploymentGroup = find(deploymentGroups, { pathName: deploymentGroupPathName });
if(deploymentGroupSlug) {
const deploymentGroup = find(deploymentGroups, { slug: deploymentGroupSlug });
if(deploymentGroup) {
return filter(services, { project: deploymentGroup.uuid });
}
@ -53,21 +90,29 @@ const resolveFunctions = {
}
return services;
},
service(_, { uuid, pathName }) {
service(_, { uuid, hash }) { // : Service
if(uuid) {
return find(services, { uuid: uuid });
}
if(pathName) {
return find(services, { pathName: pathName });
if(hash) {
return find(services, { hash: hash });
}
return null;
},
instances(_, { serviceUuid=null, servicePathName=null }) {
packages(_, { name, type, memory, disk, swap, lwps, vcpus, version, group }) { // : [Package]
return [];
},
package(_, { uuid }) { // : Package
return {};
},
instances(_, { name, machineId, status, serviceUuid, serviceSlug, deploymentGroupUuid, deploymentGroupSlug }) { // : [Instance]
if(serviceUuid) {
return filter(instances, { service: serviceUuid });
}
if(serviceId) {
const service = find(services, { pathName: servicePathName });
if(serviceSlug) {
const service = find(services, { slug: serviceSlug });
if(service) {
return filter(instances, { service: service.uuid });
}
@ -75,11 +120,21 @@ const resolveFunctions = {
}
return instances;
},
metricTypes() {
return metricTypes;
instance(_, { uuid }) { // : Instance
if(uuid) {
return find(instances, { uuid: uuid });
}
},
datacenters() {
return datacenters;
datacenter() {
return {
uuid: 'datacenter-uuid',
region: 'us-east-1'
};
},
/*metricTypes() {
return metricTypes;
},
// tmp test
instanceMetric() {
@ -91,7 +146,7 @@ const resolveFunctions = {
},
data: getInstanceMetricData(leakMetricData, 'node_memory_rss_bytes')
};
}
}*/
},
Portal: {
deploymentGroups(portal) {
@ -107,12 +162,12 @@ const resolveFunctions = {
instances(service) {
return filter(instances, { service: service.uuid });
},
metrics(service) {
/*metrics(service) {
return service.metrics ?
service.metrics.map((metric) =>
find(metricTypes, { uuid: metric.type })) : [];
},
currentMetrics(service) {
},*/
/*currentMetrics(service) {
// tmp
return [{
"name": "CPU",
@ -127,9 +182,9 @@ const resolveFunctions = {
"value": 2.9,
"measurement": "Kb/sec",
}];
},
},*/
},
Instance: {
/*Instance: {
metrics(instance) {
return ([{
type: {
@ -140,7 +195,7 @@ const resolveFunctions = {
data: normalMetricData.node_memory_rss_bytes
}]);
}
}
}*/
};
export default resolveFunctions;

View File

@ -166,9 +166,9 @@ type Query {
# we probably wont use some of these queries or arguments
# but this way we expose the entire db through gql
type Query {
portal(): Portal
portal: Portal
deploymentGroups(name: String, slug: String): [DeploymentGroup]
deploymentGroup(uuid: ID, name: String, slug: String): DeploymentGroup # WE ARE DISCUSSING THIS
deploymentGroup(uuid: ID, name: String, slug: String): DeploymentGroup
serviceScales(serviceName: String, versionUuid: ID): [ServiceScale]
serviceScale(uuid: ID!): ServiceScale
convergenceActions(type: ConvergenceActionType, service: String, versionUuid: ID): [ConvergenceAction]
@ -176,33 +176,33 @@ type Query {
stateConvergencePlans(running: Boolean, versionUuid: ID): [StateConvergencePlan]
stateConvergencePlan(uuid: ID!): StateConvergencePlan
versions(manifestUuid: ID, deploymentGroupUuid: ID): [Version]
version(uuid: ID, manifestUuid: ID): Version # WE ARE DISCUSSING THIS
version(uuid: ID, manifestUuid: ID): Version
manifests(type: String, deploymentGroupUuid: ID): [Manifest]
manifest(uuid: ID!): Manifest
services(name: String, slug: String, parent: ID, deploymentGroupUuid: ID): [Service]
service(uuid: ID, hash: ID): Service # WE ARE DISCUSSING THIS
services(name: String, slug: String, parentUuid: ID, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Service]
service(uuid: ID, hash: ID): Service
packages(name: String, type: String, memory: Int, disk: Int, swap: Int, lwps: Int, vcpus: Int, version: String, group: String): [Package]
package(uuid: ID!): Package
instances(name: String!, machineId: ID, status: InstanceStatus, serviceUuid: ID, deploymentGroupUuid: ID): [Instance]
instances(name: String!, machineId: ID, status: InstanceStatus, serviceUuid: ID, serviceSlug: String, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Instance]
instance(uuid: ID!): Instance
datacenter(uuid: ID, region: String): Datacenter
}
type Mutation {
createDeploymentGroup(name: String!)
updateDeploymentGroup(uuid: ID!, name: String!)
createDeploymentGroup(name: String!) : DeploymentGroup
updateDeploymentGroup(uuid: ID!, name: String!) : DeploymentGroup
provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!)
scale(service: ID!, replicas: Int!)
provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!) : Version
scale(service: ID!, replicas: Int!) : Version
stopServices(uuids: [ID]!)
startServices(uuids: [ID]!)
restartServices(uuids: [ID]!)
deleteServices(uuids: [ID]!)
stopServices(uuids: [ID]!) : [Service]
startServices(uuids: [ID]!) : [Service]
restartServices(uuids: [ID]!) : [Service]
deleteServices(uuids: [ID]!) : [Service]
stopInstances(uuids: [ID]!)
startInstances(uuids: [ID]!)
restartInstances(uuids: [ID]!)
stopInstances(uuids: [ID]!) : [Instance]
startInstances(uuids: [ID]!) : [Instance]
restartInstances(uuids: [ID]!) : [Instance]
# reprovision() ???
}