diff --git a/frontend/package.json b/frontend/package.json
index 80650039..041b24be 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -5,6 +5,7 @@
"dependencies": {
"apollo": "^0.2.2",
"babel-plugin-inline-react-svg": "^0.4.0",
+ "babel-plugin-styled-components": "^1.1.4",
"constant-case": "^2.0.0",
"graphql-tag": "^2.0.0",
"loadash": "^0.0.1",
diff --git a/frontend/scripts/config-overrides.dev.js b/frontend/scripts/config-overrides.dev.js
index 67af15f1..dc8a0b4c 100644
--- a/frontend/scripts/config-overrides.dev.js
+++ b/frontend/scripts/config-overrides.dev.js
@@ -23,7 +23,9 @@ module.exports = function(config) {
query: {
babelrc: false,
presets: [require.resolve('babel-preset-react-app')],
- plugins: ["inline-react-svg"],
+ plugins: [["inline-react-svg", {
+ "ignorePattern": "libre-franklin"
+ }]],
cacheDirectory: true
}
})
diff --git a/frontend/src/containers/deployment-groups/list.js b/frontend/src/containers/deployment-groups/list.js
index d499c820..728d8307 100644
--- a/frontend/src/containers/deployment-groups/list.js
+++ b/frontend/src/containers/deployment-groups/list.js
@@ -45,7 +45,7 @@ const DeploymentGroupList = ({
return (
{deploymentGroup.name}
diff --git a/frontend/src/containers/instances/list.js b/frontend/src/containers/instances/list.js
index ef813232..ebb51bd4 100644
--- a/frontend/src/containers/instances/list.js
+++ b/frontend/src/containers/instances/list.js
@@ -33,7 +33,7 @@ const InstanceListWithData = graphql(InstancesQuery, {
options(props) {
return {
variables: {
- deploymentGroupId: props.match.params.deploymentGroup
+ deploymentGroupSlug: props.match.params.deploymentGroup
}
};
},
diff --git a/frontend/src/containers/navigation/breadcrumb.js b/frontend/src/containers/navigation/breadcrumb.js
index 90d48a2c..42c497aa 100644
--- a/frontend/src/containers/navigation/breadcrumb.js
+++ b/frontend/src/containers/navigation/breadcrumb.js
@@ -38,23 +38,23 @@ const ConnectedBreadcrumb = connect(
(state, ownProps) => {
const params = ownProps.match.params;
- const deploymentGroupPathName = params.deploymentGroup;
- const servicePathName = params.service;
+ const deploymentGroupSlug = params.deploymentGroup;
+ const serviceSlug = params.service;
const apolloData = state.apollo.data;
const keys = Object.keys(apolloData);
let deploymentGroup, service;
if(keys.length) {
// These should be selectors
- if(deploymentGroupPathName) {
+ if(deploymentGroupSlug) {
deploymentGroup = keys.reduce((dg, k) =>
apolloData[k].__typename === 'DeploymentGroup' &&
- apolloData[k].pathName === deploymentGroupPathName ?
+ apolloData[k].slug === deploymentGroupSlug ?
apolloData[k] : dg, {});
- if(servicePathName) {
+ if(serviceSlug) {
service = keys.reduce((s, k) =>
apolloData[k].__typename === 'Service' &&
- apolloData[k].pathName === servicePathName ?
+ apolloData[k].slug === serviceSlug ?
apolloData[k] : s, {});
}
}
diff --git a/frontend/src/containers/navigation/menu.js b/frontend/src/containers/navigation/menu.js
index 603acf2d..f3f8e7a0 100644
--- a/frontend/src/containers/navigation/menu.js
+++ b/frontend/src/containers/navigation/menu.js
@@ -17,12 +17,12 @@ const ConnectedMenu = connect(
const params = ownProps.match.params;
const matchUrl = ownProps.match.url;
- const deploymentGroupPathName = params.deploymentGroup;
- const servicePathName = params.service;
+ const deploymentGroupSlug = params.deploymentGroup;
+ const serviceSlug = params.service;
- const sections = servicePathName ?
+ const sections = serviceSlug ?
state.ui.sections.services :
- deploymentGroupPathName ?
+ deploymentGroupSlug ?
state.ui.sections.deploymentGroups :
null;
diff --git a/frontend/src/containers/service/index.js b/frontend/src/containers/service/index.js
index 54999088..8b137891 100644
--- a/frontend/src/containers/service/index.js
+++ b/frontend/src/containers/service/index.js
@@ -1,2 +1 @@
-export { default as ServiceMetrics } from './metrics';
-export { default as SingleMetrics } from './single-metrics';
+
diff --git a/frontend/src/containers/service/metrics.js b/frontend/src/containers/service/metrics.js
deleted file mode 100644
index caf1f1c5..00000000
--- a/frontend/src/containers/service/metrics.js
+++ /dev/null
@@ -1,56 +0,0 @@
-import React, { Component } from 'react';
-import { graphql } from 'react-apollo';
-import MetricsQuery from '@graphql/Metrics.gql';
-
-class Metrics extends Component {
-
- render() {
-
- const {
- instances,
- metrics
- } = this.props;
-
- return (
-
-
-
Metrics
-
{JSON.stringify(metrics)}
-
-
- );
- }
-}
-
-const MetricsWithData = graphql(MetricsQuery, {
- options(props) {
- return {
- variables: {
- deploymentGroupId: props.match.params.deploymentGroup
- }
- };
- },
- props: ({ data: { deploymentGroup, loading, error } }) => {
-
- const instances = deploymentGroup && deploymentGroup.services ?
- deploymentGroup.services.reduce((instances, service) =>
- instances.concat(service.instances), []) : null;
-
- const metrics = instances ? instances.reduce((metrics, instance) =>
- metrics.concat(instance.metrics.map((m) =>
- Object.assign({}, m, {
- instance: {
- uuid: instance.uuid,
- name: instance.name
- }}))), []) : null;
-
- return ({
- instances,
- metrics,
- loading,
- error
- })
- }
-})(Metrics)
-
-export default MetricsWithData;
diff --git a/frontend/src/containers/service/single-metrics.js b/frontend/src/containers/service/single-metrics.js
deleted file mode 100644
index f7149b53..00000000
--- a/frontend/src/containers/service/single-metrics.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import React, { Component } from 'react';
-import { graphql } from 'react-apollo';
-import SingleMetricsQuery from '@graphql/SingleMetrics.gql';
-
-class SingleMetrics extends Component {
-
- render() {
-
- const {
- metrics
- } = this.props;
-
- return (
-
-
-
Metrics
-
{JSON.stringify(metrics)}
-
-
- );
- }
-}
-
-const SingleMetricsWithData = graphql(SingleMetricsQuery, {
- options: {
- pollInterval: 15*1000
- },
- props: ({ data: { instanceMetric, loading, error } }) => ({
- metrics: instanceMetric,
- loading,
- error
- })
-})(SingleMetrics)
-
-export default SingleMetricsWithData;
diff --git a/frontend/src/containers/services/list.js b/frontend/src/containers/services/list.js
index cd20c5d3..77c10b4d 100644
--- a/frontend/src/containers/services/list.js
+++ b/frontend/src/containers/services/list.js
@@ -20,7 +20,7 @@ class ServiceList extends Component {
services.map((service, index) =>
{service.name}
@@ -41,7 +41,7 @@ const ServiceListWithData = graphql(ServicesQuery, {
options(props) {
return {
variables: {
- deploymentGroupPathName: props.match.params.deploymentGroup
+ deploymentGroupSlug: props.match.params.deploymentGroup
}
}
},
diff --git a/frontend/src/containers/services/topology.js b/frontend/src/containers/services/topology.js
index 7f0a0409..10c2cf4a 100644
--- a/frontend/src/containers/services/topology.js
+++ b/frontend/src/containers/services/topology.js
@@ -32,12 +32,6 @@ const ServicesTopology = ({
error
}) => {
- console.log('push = ', push);
- console.log('services = ', services);
- console.log('datacenter = ', datacenter);
- console.log('loading = ', loading);
- console.log('error = ', error);
-
if(loading) {
return (
@@ -62,9 +56,9 @@ const ServicesTopology = ({
const getService = (s, i) => ({
index: i,
...s,
- metrics: s.currentMetrics.map((m) => ({
- name: m.name,
- value: `${m.value}${m.measurement}`
+ metrics: [1, 2, 3].map((m) => ({
+ name: `${m}`,
+ value: `${m}`
})),
instances: s.instances.length,
datacenter: datacenter
@@ -115,7 +109,7 @@ const ServicesGql = graphql(ServicesQuery, {
options(props) {
return {
variables: {
- deploymentGroupPathName: props.match.params.deploymentGroup
+ deploymentGroupSlug: props.match.params.deploymentGroup
}
}
},
diff --git a/frontend/src/graphql/Portal.gql b/frontend/src/graphql/Portal.gql
index 41d2aa4b..9918426c 100644
--- a/frontend/src/graphql/Portal.gql
+++ b/frontend/src/graphql/Portal.gql
@@ -2,7 +2,8 @@ query Portal {
portal {
username
datacenter {
- id
+ uuid
+ region
}
}
}
diff --git a/frontend/src/graphql/ServicesTopology.gql b/frontend/src/graphql/ServicesTopology.gql
index dfe93b4e..1f46b9c5 100644
--- a/frontend/src/graphql/ServicesTopology.gql
+++ b/frontend/src/graphql/ServicesTopology.gql
@@ -8,11 +8,6 @@ query Instances($deploymentGroupSlug: String!){
...ServiceInfo
parent
connections
- currentMetrics {
- name
- value
- measurement
- }
instances {
uuid
}
diff --git a/frontend/src/router.js b/frontend/src/router.js
index 4a795585..b05a0e82 100644
--- a/frontend/src/router.js
+++ b/frontend/src/router.js
@@ -14,8 +14,6 @@ import { DeploymentGroupList } from '@containers/deployment-groups';
import { ServiceList, ServicesTopology, ServicesMenu } from '@containers/services';
import { InstanceList } from '@containers/instances';
-import { ServiceMetrics, SingleMetrics } from '@containers/service';
-
const rootRedirect = (p) => (
);
@@ -45,6 +43,7 @@ const Router = (
+
@@ -53,8 +52,6 @@ const Router = (
-
-
diff --git a/frontend/src/state/selectors.js b/frontend/src/state/selectors.js
index caf03fda..248cc5ef 100644
--- a/frontend/src/state/selectors.js
+++ b/frontend/src/state/selectors.js
@@ -2,19 +2,19 @@ import { createSelector } from 'reselect';
const apollo = (state) => state.apollo;
-const deploymentGroupById = (deploymentGroupPathName) => createSelector(
+const deploymentGroupById = (deploymentGroupSlug) => createSelector(
[apollo],
(apollo) => apollo ? Object.keys(apollo).reduce((dg, k) =>
apollo[k].__typename === 'DeploymentGroup' &&
- apollo[k].pathName === deploymentGroupPathName ?
+ apollo[k].slug === deploymentGroupSlug ?
apollo[k] : dg, {}) : null
);
-const servicesById = (servicePathName) => createSelector(
+const servicesById = (serviceSlug) => createSelector(
[apollo],
(apollo) => apollo ? Object.keys(apollo).reduce((s, k) =>
apollo[k].__typename === 'Service' &&
- apollo[k].pathName === servicePathName ?
+ apollo[k].slug === serviceSlug ?
apollo[k] : s, {}) : null
);
diff --git a/frontend/src/state/state.js b/frontend/src/state/state.js
index 5a7abdf3..02e5421a 100644
--- a/frontend/src/state/state.js
+++ b/frontend/src/state/state.js
@@ -2,48 +2,18 @@ const state = {
ui: {
sections: {
deploymentGroups: [{
- pathname: "feed",
- name: "Feed"
- }, {
pathname: "services",
name: "Services"
}, {
pathname: "instances",
name: "Instances"
- }, {
- pathname: "rollback",
- name: "Rollback"
}, {
pathname: "manifest",
name: "Manifest"
- }, {
- pathname: "settings",
- name: "Settings"
}],
services: [{
- pathname: "summary",
- name: "Summary"
- }, {
pathname: "instances",
- name: "Insatnces"
- }, {
- pathname: "metrics",
- name: "Metrics"
- }, {
- pathname: "networks",
- name: "Networks"
- }, {
- pathname: "tags-metadata",
- name: "Tags / metadata"
- }, {
- pathname: "activity-feed",
- name: "Activity feed"
- }, {
- pathname: "manifest",
- name: "Manifest"
- }, {
- pathname: "firewall",
- name: "Firewall"
+ name: "Instances"
}]
}
}
diff --git a/frontend/src/state/store.js b/frontend/src/state/store.js
index 1c12ef5a..1b54bd0c 100644
--- a/frontend/src/state/store.js
+++ b/frontend/src/state/store.js
@@ -1,13 +1,10 @@
import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
import { ApolloClient, createNetworkInterface } from 'react-apollo';
import state from './state';
-// import uiReducer from './reducers/ui';
-
-console.log('state = ', state);
export const client = new ApolloClient({
dataIdFromObject: o => {
- const id = o.pathName ? o.pathName : o.id ? o.id : o.uuid ? o.uuid : o.timestamp ? o.timestamp : o.name ? o.name : 'apollo-cache-key-not-defined';
+ const id = o.slug ? o.slug : o.id ? o.id : o.uuid ? o.uuid : o.timestamp ? o.timestamp : o.name ? o.name : 'apollo-cache-key-not-defined';
return `${o.__typename}:${id}`;
},
networkInterface: createNetworkInterface({
diff --git a/frontend/yarn.lock b/frontend/yarn.lock
index fe90ab39..6ea9b271 100644
--- a/frontend/yarn.lock
+++ b/frontend/yarn.lock
@@ -514,6 +514,12 @@ babel-plugin-jest-hoist@^18.0.0:
version "18.0.0"
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-18.0.0.tgz#4150e70ecab560e6e7344adc849498072d34e12a"
+babel-plugin-styled-components@^1.1.4:
+ version "1.1.4"
+ resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.1.4.tgz#b0e6d5bb01059bc7ab9118d3d686f6472ee8e91f"
+ dependencies:
+ stylis "2.0.0"
+
babel-plugin-syntax-async-functions@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95"
@@ -2002,10 +2008,6 @@ esprima@^2.6.0, esprima@^2.7.1:
version "2.7.3"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-2.7.3.tgz#96e3b70d5779f6ad49cd032673d1c312767ba581"
-esprima@^3.1.1:
- version "3.1.3"
- resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"
-
esprima@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.0.0.tgz#53cf247acda77313e551c3aa2e73342d3fb4f7d9"
@@ -3207,14 +3209,7 @@ js-tokens@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.1.tgz#08e9f132484a2c45a30907e9dc4d5567b7f114d7"
-js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.7.0:
- version "3.8.4"
- resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.8.4.tgz#520b4564f86573ba96662af85a8cafa7b4b5a6f6"
- dependencies:
- argparse "^1.0.7"
- esprima "^3.1.1"
-
-js-yaml@~3.7.0:
+js-yaml@^3.4.3, js-yaml@^3.5.1, js-yaml@^3.7.0, js-yaml@~3.7.0:
version "3.7.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.7.0.tgz#5c967ddd837a9bfdca5f2de84253abe8a1c03b80"
dependencies:
@@ -5211,6 +5206,10 @@ styled-components@^1.4.6:
prop-types "^15.5.4"
supports-color "^3.1.2"
+stylis@2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/stylis/-/stylis-2.0.0.tgz#6785a6546bd73478799a67d49d67086953b50ad5"
+
supports-color@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
diff --git a/spikes/graphql/graphql-server/src/resolvers.js b/spikes/graphql/graphql-server/src/resolvers.js
index 7ffab107..e46f818c 100644
--- a/spikes/graphql/graphql-server/src/resolvers.js
+++ b/spikes/graphql/graphql-server/src/resolvers.js
@@ -2,8 +2,11 @@ import { find, filter } from 'lodash';
import data from './mock-data';
import { normalMetricData, leakMetricData } from './mock-data/metrics';
-const datacenters = data.datacenters.data;
-const portal = { username: 'juditgreskovits', host: 'dockerhost', datacenter: datacenters[0]};
+const datacenter = {
+ uuid: 'datacenter-uuid',
+ region: 'us-east-1'
+};
+const portal = { username: 'juditgreskovits', host: 'dockerhost', datacenter};
const deploymentGroups = data.projects.data.map(p => {
p.slug = p.id;
return p;
@@ -127,10 +130,7 @@ const resolveFunctions = {
},
datacenter() {
- return {
- uuid: 'datacenter-uuid',
- region: 'us-east-1'
- };
+ return datacenter;
},
/*metricTypes() {
diff --git a/spikes/graphql/graphql-server/src/schema.gql b/spikes/graphql/graphql-server/src/schema.gql
index e69de29b..33642c52 100644
--- a/spikes/graphql/graphql-server/src/schema.gql
+++ b/spikes/graphql/graphql-server/src/schema.gql
@@ -0,0 +1,204 @@
+
+ scalar Date
+ scalar Object
+
+ type Portal {
+ username: String!
+ datacenter: Datacenter!
+ deploymentGroups: [DeploymentGroup]!
+ }
+
+ type DeploymentGroup {
+ uuid: ID!
+ name: String!
+ slug: String!
+ services: [Service]!
+ version: Version!
+ history: [Version]!
+ }
+
+ type ServiceScale {
+ uuid: ID!
+ serviceName: String!
+ replicas: Int!
+ }
+
+ enum ConvergenceActionType {
+ NOOP
+ CREATE
+ RECREATE
+ START
+ }
+
+ type ConvergenceAction {
+ uuid: String!
+ type: ConvergenceActionType!
+ service: String! # service name
+ machines: [String]! # instance machine ids
+ }
+
+ type StateConvergencePlan {
+ uuid: String!
+ running: Boolean!
+ actions: [ConvergenceAction]!
+ }
+
+ type Version {
+ created: Date! # Either Int or define scalar
+ manifest: Manifest!
+ scale: [ServiceScale]!
+ plan: StateConvergencePlan
+ }
+
+ enum ManifestType {
+ COMPOSE
+ MARIPOSA
+ }
+
+ enum ManifestFormat {
+ JSON
+ YAML
+ }
+
+ type Manifest {
+ uuid: String!
+ created: Date!
+ type: ManifestType!
+ format: ManifestFormat!
+ raw: String!
+ obj: Object!
+ }
+
+ # immutable
+ type Service {
+ uuid: String! # unique id for db row
+ hash: String! # unique id for version of service
+ name: String! # human readable name
+ slug: String!
+ instances: [Instance]!
+ # metrics: [MetricType]!
+ currentMetrics: [CurrentMetric]!
+ connections: [String!] # list of serviceUuids
+ parent: ID # parent service uuid
+ package: Package! # we don't have this in current mock data
+ }
+
+ # for metrics max / min (I guess)
+ type Package {
+ uuid: ID!
+ name: String!
+ type: String!
+ memory: Float!
+ disk: Float!
+ swap: Float!
+ lwps: Int!
+ vcpus: Int!
+ version: String!
+ group: String!
+ }
+
+ enum InstanceStatus {
+ CREATED
+ RESTARTING
+ RUNNING
+ PAUSED
+ EXITED
+ DELETED
+ }
+
+ type Instance {
+ uuid: String!
+ name: String!
+ machineId: String!
+ status: InstanceStatus!
+ # metrics: [InstanceMetric]!
+ }
+
+ type Datacenter {
+ uuid: String!
+ # name: String! # Do we have 'official' human readable names?
+ region: String!
+ }
+
+ type InstanceMetric {
+ type: MetricType!
+ data: [MetricData]!
+ }
+
+ type CurrentMetric {
+ name: String!
+ value: Float!
+ measurement: String!
+ }
+
+ type MetricType {
+ uuid: String!
+ name: String!
+ id: String!
+ }
+
+ type MetricData {
+ timestamp: Int!
+ value: Float!
+ }
+
+ # Need to review queries
+ type Query {
+ portal: Portal
+ deploymentGroups: [DeploymentGroup]
+ deploymentGroup(uuid: String, slug: String): DeploymentGroup
+ services(deploymentGroupUuid: String, deploymentGroupSlug: String): [Service]
+ service(uuid: String, slug: String): Service
+ instances(serviceUuid: String, serviceSlug: String): [Instance]
+ instance(uuid: String, machineId: String): Instance
+ metricTypes: [MetricType]
+ metricData(instanceUuid: String!, metricType: String!, from: Date!, to: Date!): [InstanceMetric]!
+ package: Package
+ datacenters: [Datacenter]
+ # tmp test
+ instanceMetric: InstanceMetric!
+ }
+
+ # we probably wont use some of these queries or arguments
+ # but this way we expose the entire db through gql
+ type Query {
+ portal: Portal
+ deploymentGroups(name: String, slug: String): [DeploymentGroup]
+ 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]
+ convergenceAction(uuid: ID!): ConvergenceAction
+ stateConvergencePlans(running: Boolean, versionUuid: ID): [StateConvergencePlan]
+ stateConvergencePlan(uuid: ID!): StateConvergencePlan
+ versions(manifestUuid: ID, deploymentGroupUuid: ID): [Version]
+ version(uuid: ID, manifestUuid: ID): Version
+ manifests(type: String, deploymentGroupUuid: ID): [Manifest]
+ manifest(uuid: ID!): Manifest
+ 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, serviceSlug: String, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Instance]
+ instance(uuid: ID!): Instance
+ datacenter(uuid: ID, region: String): Datacenter
+ }
+
+ type Mutation {
+ createDeploymentGroup(name: String!) : DeploymentGroup
+ updateDeploymentGroup(uuid: ID!, name: String!) : DeploymentGroup
+
+ provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!) : Version
+ scale(service: ID!, replicas: Int!) : Version
+
+ stopServices(uuids: [ID]!) : [Service]
+ startServices(uuids: [ID]!) : [Service]
+ restartServices(uuids: [ID]!) : [Service]
+ deleteServices(uuids: [ID]!) : [Service]
+
+ stopInstances(uuids: [ID]!) : [Instance]
+ startInstances(uuids: [ID]!) : [Instance]
+ restartInstances(uuids: [ID]!) : [Instance]
+
+ # reprovision() ???
+ }
diff --git a/spikes/graphql/graphql-server/src/schema.js b/spikes/graphql/graphql-server/src/schema.js
index ee317e1b..de42f680 100644
--- a/spikes/graphql/graphql-server/src/schema.js
+++ b/spikes/graphql/graphql-server/src/schema.js
@@ -1,213 +1,9 @@
+import path from 'path';
+import { readFileSync } from 'fs';
import { makeExecutableSchema } from 'graphql-tools';
import resolvers from './resolvers';
-const schema = `
-
-scalar Date
-scalar Object
-
-type Portal {
- username: String!
- datacenter: Datacenter!
- deploymentGroups: [DeploymentGroup]!
-}
-
-type DeploymentGroup {
- uuid: ID!
- name: String!
- slug: String!
- services: [Service]!
- version: Version!
- history: [Version]!
-}
-
-type ServiceScale {
- uuid: ID!
- serviceName: String!
- replicas: Int!
-}
-
-enum ConvergenceActionType {
- NOOP
- CREATE
- RECREATE
- START
- }
-
-type ConvergenceAction {
- uuid: String!
- type: ConvergenceActionType!
- service: String! # service name
- machines: [String]! # instance machine ids
-}
-
-type StateConvergencePlan {
- uuid: String!
- running: Boolean!
- actions: [ConvergenceAction]!
-}
-
-type Version {
- created: Date! # Either Int or define scalar
- manifest: Manifest!
- scale: [ServiceScale]!
- plan: StateConvergencePlan
-}
-
-enum ManifestType {
- COMPOSE
- MARIPOSA
-}
-
-enum ManifestFormat {
- JSON
- YAML
-}
-
-type Manifest {
- uuid: String!
- created: Date!
- type: ManifestType!
- format: ManifestFormat!
- raw: String!
- obj: Object!
-}
-
-# immutable
-type Service {
- uuid: String! # unique id for db row
- hash: String! # unique id for version of service
- name: String! # human readable name
- slug: String!
- instances: [Instance]!
- # metrics: [MetricType]!
- currentMetrics: [CurrentMetric]!
- connections: [String!] # list of serviceUuids
- parent: ID # parent service uuid
- package: Package! # we don't have this in current mock data
-}
-
-# for metrics max / min (I guess)
-type Package {
- uuid: ID!
- name: String!
- type: String!
- memory: Float!
- disk: Float!
- swap: Float!
- lwps: Int!
- vcpus: Int!
- version: String!
- group: String!
-}
-
-enum InstanceStatus {
- CREATED
- RESTARTING
- RUNNING
- PAUSED
- EXITED
- DELETED
-}
-
-type Instance {
- uuid: String!
- name: String!
- machineId: String!
- status: InstanceStatus!
- # metrics: [InstanceMetric]!
-}
-
-type Datacenter {
- uuid: String!
- # name: String! # Do we have 'official' human readable names?
- region: String!
-}
-
-type InstanceMetric {
- type: MetricType!
- data: [MetricData]!
-}
-
-type CurrentMetric {
- name: String!
- value: Float!
- measurement: String!
-}
-
-type MetricType {
- uuid: String!
- name: String!
- id: String!
-}
-
-type MetricData {
- timestamp: Int!
- value: Float!
-}
-
-# Need to review queries
-type Query {
- portal: Portal
- deploymentGroups: [DeploymentGroup]
- deploymentGroup(uuid: String, slug: String): DeploymentGroup
- services(deploymentGroupUuid: String, deploymentGroupSlug: String): [Service]
- service(uuid: String, slug: String): Service
- instances(serviceUuid: String, serviceSlug: String): [Instance]
- instance(uuid: String, machineId: String): Instance
- metricTypes: [MetricType]
- metricData(instanceUuid: String!, metricType: String!, from: Date!, to: Date!): [InstanceMetric]!
- package: Package
- datacenters: [Datacenter]
- # tmp test
- instanceMetric: InstanceMetric!
-}
-
-# we probably wont use some of these queries or arguments
-# but this way we expose the entire db through gql
-type Query {
- portal: Portal
- deploymentGroups(name: String, slug: String): [DeploymentGroup]
- 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]
- convergenceAction(uuid: ID!): ConvergenceAction
- stateConvergencePlans(running: Boolean, versionUuid: ID): [StateConvergencePlan]
- stateConvergencePlan(uuid: ID!): StateConvergencePlan
- versions(manifestUuid: ID, deploymentGroupUuid: ID): [Version]
- version(uuid: ID, manifestUuid: ID): Version
- manifests(type: String, deploymentGroupUuid: ID): [Manifest]
- manifest(uuid: ID!): Manifest
- 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, serviceSlug: String, deploymentGroupUuid: ID, deploymentGroupSlug: String): [Instance]
- instance(uuid: ID!): Instance
- datacenter(uuid: ID, region: String): Datacenter
-}
-
-type Mutation {
- createDeploymentGroup(name: String!) : DeploymentGroup
- updateDeploymentGroup(uuid: ID!, name: String!) : DeploymentGroup
-
- provisionManifest(deploymentGroupUuid: ID!, type: ManifestType!, format: ManifestFormat!, raw: String!) : Version
- scale(service: ID!, replicas: Int!) : Version
-
- stopServices(uuids: [ID]!) : [Service]
- startServices(uuids: [ID]!) : [Service]
- restartServices(uuids: [ID]!) : [Service]
- deleteServices(uuids: [ID]!) : [Service]
-
- stopInstances(uuids: [ID]!) : [Instance]
- startInstances(uuids: [ID]!) : [Instance]
- restartInstances(uuids: [ID]!) : [Instance]
-
- # reprovision() ???
-}
-
-`;
+const schema = readFileSync(path.join(__dirname, 'schema.gql'), 'utf8');
export default makeExecutableSchema({
typeDefs: schema,