From 4b2e0f53ae7641a0589d3385ad0e8d7be71ad947 Mon Sep 17 00:00:00 2001 From: JUDIT GRESKOVITS Date: Wed, 17 May 2017 17:10:18 +0100 Subject: [PATCH] Update resolvers accoring to latest schema --- frontend/src/graphql/DeploymentGroupInfo.gql | 2 +- frontend/src/graphql/Instances.gql | 4 +- frontend/src/graphql/Metrics.gql | 25 ---- frontend/src/graphql/Portal.gql | 1 - frontend/src/graphql/ServiceInfo.gql | 2 +- frontend/src/graphql/Services.gql | 4 +- frontend/src/graphql/ServicesTopology.gql | 4 +- frontend/src/graphql/SingleMetrics.gql | 2 +- .../graphql/graphql-server/src/resolvers.js | 107 +++++++++++++----- spikes/graphql/graphql-server/src/schema.gql | 0 spikes/graphql/graphql-server/src/schema.js | 34 +++--- 11 files changed, 107 insertions(+), 78 deletions(-) delete mode 100644 frontend/src/graphql/Metrics.gql create mode 100644 spikes/graphql/graphql-server/src/schema.gql diff --git a/frontend/src/graphql/DeploymentGroupInfo.gql b/frontend/src/graphql/DeploymentGroupInfo.gql index 49dd1b71..93df779f 100644 --- a/frontend/src/graphql/DeploymentGroupInfo.gql +++ b/frontend/src/graphql/DeploymentGroupInfo.gql @@ -1,5 +1,5 @@ fragment DeploymentGroupInfo on DeploymentGroup { uuid name - pathName + slug } diff --git a/frontend/src/graphql/Instances.gql b/frontend/src/graphql/Instances.gql index 3b26120d..23ee6298 100644 --- a/frontend/src/graphql/Instances.gql +++ b/frontend/src/graphql/Instances.gql @@ -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 diff --git a/frontend/src/graphql/Metrics.gql b/frontend/src/graphql/Metrics.gql deleted file mode 100644 index b48b2dc1..00000000 --- a/frontend/src/graphql/Metrics.gql +++ /dev/null @@ -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 - } - } - } - } - } -} diff --git a/frontend/src/graphql/Portal.gql b/frontend/src/graphql/Portal.gql index e94c1ebc..41d2aa4b 100644 --- a/frontend/src/graphql/Portal.gql +++ b/frontend/src/graphql/Portal.gql @@ -1,7 +1,6 @@ query Portal { portal { username - host datacenter { id } diff --git a/frontend/src/graphql/ServiceInfo.gql b/frontend/src/graphql/ServiceInfo.gql index 26d4f520..0a1d01ef 100644 --- a/frontend/src/graphql/ServiceInfo.gql +++ b/frontend/src/graphql/ServiceInfo.gql @@ -1,5 +1,5 @@ fragment ServiceInfo on Service { uuid name - pathName + slug } diff --git a/frontend/src/graphql/Services.gql b/frontend/src/graphql/Services.gql index 1eebffa4..a572584d 100644 --- a/frontend/src/graphql/Services.gql +++ b/frontend/src/graphql/Services.gql @@ -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 diff --git a/frontend/src/graphql/ServicesTopology.gql b/frontend/src/graphql/ServicesTopology.gql index de494a93..dfe93b4e 100644 --- a/frontend/src/graphql/ServicesTopology.gql +++ b/frontend/src/graphql/ServicesTopology.gql @@ -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 diff --git a/frontend/src/graphql/SingleMetrics.gql b/frontend/src/graphql/SingleMetrics.gql index 14798f56..2eec5a72 100644 --- a/frontend/src/graphql/SingleMetrics.gql +++ b/frontend/src/graphql/SingleMetrics.gql @@ -3,7 +3,7 @@ query SingleMetrics { type { uuid name - id + machineId } data { timestamp diff --git a/spikes/graphql/graphql-server/src/resolvers.js b/spikes/graphql/graphql-server/src/resolvers.js index 5c87590f..7ffab107 100644 --- a/spikes/graphql/graphql-server/src/resolvers.js +++ b/spikes/graphql/graphql-server/src/resolvers.js @@ -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; diff --git a/spikes/graphql/graphql-server/src/schema.gql b/spikes/graphql/graphql-server/src/schema.gql new file mode 100644 index 00000000..e69de29b diff --git a/spikes/graphql/graphql-server/src/schema.js b/spikes/graphql/graphql-server/src/schema.js index 4431cf44..ee317e1b 100644 --- a/spikes/graphql/graphql-server/src/schema.js +++ b/spikes/graphql/graphql-server/src/schema.js @@ -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() ??? }