add gql tag and fix up vm domains

Signed-off-by: Alexis Tyler <xo@wvvw.me>
This commit is contained in:
Alexis Tyler
2019-07-01 13:35:07 +09:30
parent d278c68dd2
commit c7f681bc0c
11 changed files with 32 additions and 24 deletions

View File

@@ -10,12 +10,12 @@
* all copies or substantial portions of the Software.
*/
module.exports = function ($injector, get, graphql, graphqlDirective, mergeGraphqlSchemas, ApiManager, log, typeDefs, resolvers, AppError, PluginManager, PluginError) {
module.exports = function ($injector, get, gql, graphql, graphqlDirective, mergeGraphqlSchemas, ApiManager, log, typeDefs, resolvers, AppError, PluginManager, PluginError) {
const { buildSchema } = graphql;
const { addDirectiveResolveFunctionsToSchema } = graphqlDirective;
const { mergeTypes } = mergeGraphqlSchemas;
const types = mergeTypes([`
const types = mergeTypes([gql`
scalar JSON
scalar Long
scalar UUID
@@ -35,19 +35,21 @@ module.exports = function ($injector, get, graphql, graphqlDirective, mergeGraph
type Query {
me: User
app(id: String!): App @func(module: "apps/app/get-app")
apps: [App!]! @func(module: "get-apps", result:"json")
apps: [App!]! @func(module: "get-apps", result: "json")
device(id: String!): Device @func(module: "devices/device/get-device")
devices: [Device!]! @func(module: "get-devices", result:"json")
devices: [Device!]! @func(module: "get-devices", result: "json")
info: Info @container
unassignedDevices: [UnassignedDevice] @func(module: "get-unassigned-devices", result:"json")
user(id: String!): User @func(module: "users/user/get-user", result:"json")
users: [User!]! @func(module: "get-users", result:"json")
plugins: [Plugin] @func(module: "get-plugins", result:"json")
pluginModule(plugin: String!, module: String!, params: JSON, result: String): JSON @func(result:"json")
service(name: String!): Service @func(module: "services/name/get-service", result:"json")
services: [Service] @func(module: "get-services", result:"json")
shares: [Share] @func(module: "get-shares", result:"json")
vars: Vars @func(module: "get-vars", result:"json")
unassignedDevices: [UnassignedDevice] @func(module: "get-unassigned-devices", result: "json")
user(id: String!): User @func(module: "users/user/get-user", result: "json")
users: [User!]! @func(module: "get-users", result: "json")
plugins: [Plugin] @func(module: "get-plugins", result: "json")
pluginModule(plugin: String!, module: String!, params: JSON, result: String): JSON @func(result: "json")
service(name: String!): Service @func(module: "services/name/get-service", result: "json")
services: [Service] @func(module: "get-services", result: "json")
shares: [Share] @func(module: "get-shares", result: "json")
vars: Vars @func(module: "get-vars", result: "json")
vm(name: String!): Domain @func(module: "vms/domains/domain/get-domain", result: "json")
vms: Vms @container
}
`, typeDefs]);
@@ -110,7 +112,7 @@ module.exports = function ($injector, get, graphql, graphqlDirective, mergeGraph
let contextParams = params;
let funcPath = path.join(coreCwd, moduleName + '.js');
// If we're looking for a plugin verifiy it's installed and active first
// If we're looking for a plugin verify it's installed and active first
if (params.plugin) {
if (!PluginManager.isInstalled(pluginName, pluginModuleName)) {
throw new PluginError('Plugin not installed.');

View File

@@ -1,5 +1,5 @@
type Info {
apps: InfoApps @func(module: "info/get-apps", result:"json")
apps: InfoApps @func(module: "info/get-apps", result: "json")
}
type InfoApps {

View File

@@ -1,5 +1,5 @@
type Info {
array: InfoArray @func(module: "info/get-array", result:"json")
array: InfoArray @func(module: "info/get-array", result: "json")
}
enum InfoArrayState {

View File

@@ -1,5 +1,5 @@
type Info {
devices: Devices @func(module: "info/get-devices", result:"json")
devices: Devices @func(module: "info/get-devices", result: "json")
}
type Devices {

View File

@@ -1,5 +1,5 @@
type Info {
os: Os @func(module: "info/get-os", result:"json")
os: Os @func(module: "info/get-os", result: "json")
}
type Os {

View File

@@ -1,5 +1,5 @@
type Info {
system: System @func(module: "info/get-system", result:"json")
system: System @func(module: "info/get-system", result: "json")
}
type System {

View File

@@ -1,5 +1,5 @@
type Info {
versions: Versions @func(module: "info/get-versions", result:"json")
versions: Versions @func(module: "info/get-versions", result: "json")
}
type Versions {

View File

@@ -1,5 +1,9 @@
type Vms {
domains: Domain @func(module: "vms/get-domains", result: "json")
}
"""A virtual machine"""
type Vm {
type Domain {
uuid: ID!
"""Operating system type"""
osType: String

View File

@@ -43,7 +43,8 @@ $injector.registerImports({
mergeGraphqlSchemas: 'merge-graphql-schemas',
GraphQLJSON: 'graphql-type-json',
GraphQLLong: 'graphql-type-long',
GraphQLUUID: 'graphql-type-uuid'
GraphQLUUID: 'graphql-type-uuid',
gql: 'graphql-tag'
}, module);
// Register all of the single js files as modules.

View File

@@ -19,6 +19,7 @@
"got": "^9.6.0",
"graphql": "^14.3.1",
"graphql-directive": "^0.2.1",
"graphql-tag": "^2.10.1",
"graphql-type-json": "^0.3.0",
"graphql-type-long": "^0.1.1",
"graphql-type-uuid": "^0.2.0",
@@ -49,4 +50,4 @@
"p-props",
"stoppable"
]
}
}

View File

@@ -1463,7 +1463,7 @@ graphql-subscriptions@^1.0.0:
dependencies:
iterall "^1.2.1"
graphql-tag@^2.9.2:
graphql-tag@^2.10.1, graphql-tag@^2.9.2:
version "2.10.1"
resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.10.1.tgz#10aa41f1cd8fae5373eaf11f1f67260a3cad5e02"
integrity sha512-jApXqWBzNXQ8jYa/HLkZJaVw9jgwNqZkywa2zfFn16Iv1Zb7ELNHkJaXHR7Quvd5SIGsy6Ny7SUKATgnu05uEg==