feat(cloudapi-gql): add machine links
This commit is contained in:
parent
77540223ab
commit
6c5a75fe89
@ -2,7 +2,8 @@ const forceArray = require('force-array');
|
|||||||
const hasha = require('hasha');
|
const hasha = require('hasha');
|
||||||
|
|
||||||
module.exports.toKeyValue = r =>
|
module.exports.toKeyValue = r =>
|
||||||
r && Object.keys(r).map(name => ({
|
r &&
|
||||||
|
Object.keys(r).map(name => ({
|
||||||
id: hasha(JSON.stringify({ name, value: r[name] })),
|
id: hasha(JSON.stringify({ name, value: r[name] })),
|
||||||
name,
|
name,
|
||||||
value: r[name]
|
value: r[name]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const request = require('./request');
|
const request = require('./request');
|
||||||
|
|
||||||
module.exports.list = ctx => request('listPackages', ctx);
|
module.exports.list = ctx => request('listPackages', ctx);
|
||||||
module.exports.get = ctx => request('getPackage', ctx);
|
module.exports.get = ({ id, name }) =>
|
||||||
|
request.fetch(`/:login/packages/${id || name}`);
|
||||||
|
@ -40,7 +40,7 @@ const resolvers = {
|
|||||||
id
|
id
|
||||||
? api.packages.get({ id }).then(pkg => [pkg])
|
? api.packages.get({ id }).then(pkg => [pkg])
|
||||||
: api.packages.list(rest),
|
: api.packages.list(rest),
|
||||||
package: (root, { id }) => api.packages.get({ id }),
|
package: (root, { id, name }) => api.packages.get({ id, name }),
|
||||||
machines: (root, { id, brand, state, tags, ...rest }) =>
|
machines: (root, { id, brand, state, tags, ...rest }) =>
|
||||||
id
|
id
|
||||||
? api.machines.get({ id }).then(machine => [machine])
|
? api.machines.get({ id }).then(machine => [machine])
|
||||||
@ -103,16 +103,20 @@ const resolvers = {
|
|||||||
keys: ({ login }, { name }) => resolvers.Query.keys(null, { login, name })
|
keys: ({ login }, { name }) => resolvers.Query.keys(null, { login, name })
|
||||||
},
|
},
|
||||||
Machine: {
|
Machine: {
|
||||||
|
brand: ({ brand }) => (brand ? brand.toUpperCase() : brand),
|
||||||
state: ({ state }) => (state ? state.toUpperCase() : state),
|
state: ({ state }) => (state ? state.toUpperCase() : state),
|
||||||
|
image: ({ image }) => resolvers.Query.image(null, { id: image }),
|
||||||
tags: ({ id }, { name }) =>
|
tags: ({ id }, { name }) =>
|
||||||
resolvers.Query.tags(null, { machine: id, name }),
|
resolvers.Query.tags(null, { machine: id, name }),
|
||||||
metadata: ({ id }, { name }) =>
|
metadata: ({ id }, { name }) =>
|
||||||
resolvers.Query.metadata(null, { machine: id, name }),
|
resolvers.Query.metadata(null, { machine: id, name }),
|
||||||
snapshots: ({ id }, { name }) =>
|
|
||||||
resolvers.Query.snapshots(null, { machine: id, name }),
|
|
||||||
networks: ({ networks }) =>
|
networks: ({ networks }) =>
|
||||||
Promise.all(networks.map(id => resolvers.Query.network(null, { id }))),
|
Promise.all(networks.map(id => resolvers.Query.network(null, { id }))),
|
||||||
// eslint-disable-next-line camelcase
|
// eslint-disable-next-line camelcase
|
||||||
|
package: (root) => resolvers.Query.package(null, { name: root.package }),
|
||||||
|
snapshots: ({ id }, { name }) =>
|
||||||
|
resolvers.Query.snapshots(null, { machine: id, name }),
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
firewall_rules: ({ id: machine }, { id }) =>
|
firewall_rules: ({ id: machine }, { id }) =>
|
||||||
resolvers.Query.firewall_rules(null, { machine, id }),
|
resolvers.Query.firewall_rules(null, { machine, id }),
|
||||||
actions: ({ id }) => resolvers.Query.actions(null, { machine: id })
|
actions: ({ id }) => resolvers.Query.actions(null, { machine: id })
|
||||||
@ -128,6 +132,7 @@ const resolvers = {
|
|||||||
},
|
},
|
||||||
Caller: {
|
Caller: {
|
||||||
type: ({ type }) => (type ? type.toUpperCase() : type),
|
type: ({ type }) => (type ? type.toUpperCase() : type),
|
||||||
|
// eslint-disable-next-line camelcase
|
||||||
key_id: ({ keyId }) => keyId
|
key_id: ({ keyId }) => keyId
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -562,6 +562,8 @@ type Query {
|
|||||||
package(
|
package(
|
||||||
# The id of for this package
|
# The id of for this package
|
||||||
id: ID
|
id: ID
|
||||||
|
# The "friendly" name for this package
|
||||||
|
name: String
|
||||||
): Package
|
): Package
|
||||||
# Lists all instances we have on record for your account
|
# Lists all instances we have on record for your account
|
||||||
machines(
|
machines(
|
||||||
|
@ -1180,9 +1180,10 @@ babel-plugin-minify-type-constructors@^0.2.0:
|
|||||||
babel-helper-is-void-0 "^0.2.0"
|
babel-helper-is-void-0 "^0.2.0"
|
||||||
|
|
||||||
babel-plugin-styled-components@^1.1.7, babel-plugin-styled-components@^1.2.0:
|
babel-plugin-styled-components@^1.1.7, babel-plugin-styled-components@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.2.0.tgz#8bb8f9e69119bb8dee408c8d36a0dfef5191f3c7"
|
resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.2.1.tgz#e1593f2a6a0327e2d156695306e60c4dd175866d"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
babel-types "^6.26.0"
|
||||||
stylis "^3.2.1"
|
stylis "^3.2.1"
|
||||||
|
|
||||||
babel-plugin-syntax-async-functions@^6.8.0:
|
babel-plugin-syntax-async-functions@^6.8.0:
|
||||||
@ -12737,8 +12738,8 @@ vise@2.x.x:
|
|||||||
hoek "4.x.x"
|
hoek "4.x.x"
|
||||||
|
|
||||||
vlq@^0.2.1:
|
vlq@^0.2.1:
|
||||||
version "0.2.2"
|
version "0.2.3"
|
||||||
resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.2.tgz#e316d5257b40b86bb43cb8d5fea5d7f54d6b0ca1"
|
resolved "https://registry.yarnpkg.com/vlq/-/vlq-0.2.3.tgz#8f3e4328cf63b1540c0d67e1b2778386f8975b26"
|
||||||
|
|
||||||
vm-browserify@0.0.4:
|
vm-browserify@0.0.4:
|
||||||
version "0.0.4"
|
version "0.0.4"
|
||||||
|
Loading…
Reference in New Issue
Block a user