@@ -51,6 +55,7 @@ const Router = (
+
diff --git a/frontend/src/state/selectors.js b/frontend/src/state/selectors.js
index 231b685e..b8b082b4 100644
--- a/frontend/src/state/selectors.js
+++ b/frontend/src/state/selectors.js
@@ -6,18 +6,20 @@ const apollo = (state) => state.apollo;
const deploymentGroupBySlug = (deploymentGroupSlug) => createSelector(
[apollo],
- (apollo) => apollo ? Object.keys(apollo).reduce((dg, k) =>
- apollo[k].__typename === 'DeploymentGroup' &&
- apollo[k].slug === deploymentGroupSlug ?
- apollo[k] : dg, {}) : null
+ (apollo) => apollo && apollo.data ?
+ Object.keys(apollo.data).reduce((dg, k) =>
+ apollo.data[k].__typename === 'DeploymentGroup' &&
+ apollo.data[k].slug === deploymentGroupSlug ?
+ apollo.data[k] : dg, null) : null
);
-const servicesBySlug = (serviceSlug) => createSelector(
+const serviceBySlug = (serviceSlug) => createSelector(
[apollo],
- (apollo) => apollo ? Object.keys(apollo).reduce((s, k) =>
- apollo[k].__typename === 'Service' &&
- apollo[k].slug === serviceSlug ?
- apollo[k] : s, {}) : null
+ (apollo) => apollo && apollo.data ?
+ Object.keys(apollo.data).reduce((s, k) =>
+ apollo.data[k].__typename === 'Service' &&
+ apollo.data[k].slug === serviceSlug ?
+ apollo.data[k] : s, null) : null
);
// apollo gql utils //
@@ -64,6 +66,6 @@ const processServices = (services, datacenter) => {
export {
deploymentGroupBySlug as deploymentGroupBySlugSelector,
- servicesBySlug as servicesBySlugSelector,
+ serviceBySlug as serviceBySlugSelector,
processServices as processServices
}
diff --git a/spikes/graphql/graphql-server/src/resolvers.js b/spikes/graphql/graphql-server/src/resolvers.js
index e46f818c..5c751c6b 100644
--- a/spikes/graphql/graphql-server/src/resolvers.js
+++ b/spikes/graphql/graphql-server/src/resolvers.js
@@ -2,6 +2,7 @@ import { find, filter } from 'lodash';
import data from './mock-data';
import { normalMetricData, leakMetricData } from './mock-data/metrics';
+// TMP / Util
const datacenter = {
uuid: 'datacenter-uuid',
region: 'us-east-1'
@@ -26,140 +27,148 @@ const getInstanceMetricData = (dataset, type) => {
const tick = setInterval(() => index++, 15*1000);
-const resolveFunctions = {
- Query: {
- portal() {
- return portal;
- },
+// GraphQL
- deploymentGroups(_, { name, slug }) {
- return deploymentGroups;
- },
- deploymentGroup(_, { uuid, name, slug }) {
- if(uuid) {
- return find(deploymentGroups, { uuid: uuid });
- }
- if(slug) {
- return find(deploymentGroups, { slug: slug });
- }
- return 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(deploymentGroupSlug) {
- const deploymentGroup = find(deploymentGroups, { slug: deploymentGroupSlug });
- if(deploymentGroup) {
- return filter(services, { project: deploymentGroup.uuid });
- }
- return null;
- }
- return services;
- },
- service(_, { uuid, hash }) { // : Service
- if(uuid) {
- return find(services, { uuid: uuid });
- }
- if(hash) {
- return find(services, { hash: hash });
- }
- return 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(serviceSlug) {
- const service = find(services, { slug: serviceSlug });
- if(service) {
- return filter(instances, { service: service.uuid });
- }
- return null;
- }
- return instances;
- },
- instance(_, { uuid }) { // : Instance
- if(uuid) {
- return find(instances, { uuid: uuid });
- }
- },
-
- datacenter() {
- return datacenter;
- },
-
- /*metricTypes() {
- return metricTypes;
- },
- // tmp test
- instanceMetric() {
- return {
- type: {
- uuid: 'node_memory_rss_bytes',
- id: 'node_memory_rss_bytes',
- name: 'node_memory_rss_bytes',
- },
- data: getInstanceMetricData(leakMetricData, 'node_memory_rss_bytes')
- };
- }*/
+const queries = {
+ portal() {
+ return portal;
},
+
+ deploymentGroups(_, { name, slug }) {
+ return deploymentGroups;
+ },
+ deploymentGroup(_, { uuid, name, slug }) {
+ if(uuid) {
+ return find(deploymentGroups, { uuid: uuid });
+ }
+ if(slug) {
+ return find(deploymentGroups, { slug: slug });
+ }
+ return 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(deploymentGroupSlug) {
+ const deploymentGroup = find(deploymentGroups, { slug: deploymentGroupSlug });
+ if(deploymentGroup) {
+ if(slug) {
+ return filter(services, { project: deploymentGroup.uuid, slug: slug });
+ }
+ return filter(services, { project: deploymentGroup.uuid });
+ }
+ return null;
+ }
+ return services;
+ },
+ service(_, { uuid, hash }) { // : Service
+ if(uuid) {
+ return find(services, { uuid: uuid });
+ }
+ if(hash) {
+ return find(services, { hash: hash });
+ }
+ return 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(serviceSlug) {
+ const service = find(services, { slug: serviceSlug });
+ if(service) {
+ return filter(instances, { service: service.uuid });
+ }
+ return null;
+ }
+ return instances;
+ },
+ instance(_, { uuid }) { // : Instance
+ if(uuid) {
+ return find(instances, { uuid: uuid });
+ }
+ },
+
+ datacenter() {
+ return datacenter;
+ },
+
+ /*metricTypes() {
+ return metricTypes;
+ },
+ // tmp test
+ instanceMetric() {
+ return {
+ type: {
+ uuid: 'node_memory_rss_bytes',
+ id: 'node_memory_rss_bytes',
+ name: 'node_memory_rss_bytes',
+ },
+ data: getInstanceMetricData(leakMetricData, 'node_memory_rss_bytes')
+ };
+ }*/
+}
+
+const resolveFunctions = {
+ Query: queries,
Portal: {
- deploymentGroups(portal) {
+ deploymentGroups(portal, args, context) {
return deploymentGroups;
}
},
DeploymentGroup: {
- services(deploymentGroup) {
- return filter(services, { project: deploymentGroup.uuid });
- },
+ services(deploymentGroup, args, context) {
+ const a = Object.assign({}, args, {deploymentGroupSlug: deploymentGroup.slug})
+ return queries.services(null, a);
+ }
},
Service: {
- instances(service) {
+ instances(service, args, context) {
return filter(instances, { service: service.uuid });
},
/*metrics(service) {
diff --git a/spikes/graphql/graphql-server/src/schema.gql b/spikes/graphql/graphql-server/src/schema.gql
index 33642c52..73cf8ef0 100644
--- a/spikes/graphql/graphql-server/src/schema.gql
+++ b/spikes/graphql/graphql-server/src/schema.gql
@@ -12,7 +12,7 @@
uuid: ID!
name: String!
slug: String!
- services: [Service]!
+ services(slug: String): [Service]!
version: Version!
history: [Version]!
}