diff --git a/app/graphql/index.js b/app/graphql/index.js index 9a3d67a86..a46f029c6 100644 --- a/app/graphql/index.js +++ b/app/graphql/index.js @@ -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.'); diff --git a/app/graphql/schema/types/info/apps.graphql b/app/graphql/schema/types/info/apps.graphql index 46f60e681..69507bb08 100644 --- a/app/graphql/schema/types/info/apps.graphql +++ b/app/graphql/schema/types/info/apps.graphql @@ -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 { diff --git a/app/graphql/schema/types/info/array.graphql b/app/graphql/schema/types/info/array.graphql index 61f17b104..de146ea71 100644 --- a/app/graphql/schema/types/info/array.graphql +++ b/app/graphql/schema/types/info/array.graphql @@ -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 { diff --git a/app/graphql/schema/types/info/devices.graphql b/app/graphql/schema/types/info/devices.graphql index 9999bcfd3..049b589fb 100644 --- a/app/graphql/schema/types/info/devices.graphql +++ b/app/graphql/schema/types/info/devices.graphql @@ -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 { diff --git a/app/graphql/schema/types/info/os.graphql b/app/graphql/schema/types/info/os.graphql index 78d67e475..8c54aa5a3 100644 --- a/app/graphql/schema/types/info/os.graphql +++ b/app/graphql/schema/types/info/os.graphql @@ -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 { diff --git a/app/graphql/schema/types/info/system.graphql b/app/graphql/schema/types/info/system.graphql index 2a266951a..58b902c6b 100644 --- a/app/graphql/schema/types/info/system.graphql +++ b/app/graphql/schema/types/info/system.graphql @@ -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 { diff --git a/app/graphql/schema/types/info/versions.graphql b/app/graphql/schema/types/info/versions.graphql index f315ea6bd..99589683d 100644 --- a/app/graphql/schema/types/info/versions.graphql +++ b/app/graphql/schema/types/info/versions.graphql @@ -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 { diff --git a/app/graphql/schema/types/vms/vm.graphql b/app/graphql/schema/types/vms/domain.graphql similarity index 88% rename from app/graphql/schema/types/vms/vm.graphql rename to app/graphql/schema/types/vms/domain.graphql index c57f75de3..939815d5a 100644 --- a/app/graphql/schema/types/vms/vm.graphql +++ b/app/graphql/schema/types/vms/domain.graphql @@ -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 diff --git a/app/index.js b/app/index.js index a09d53dc2..425802da0 100644 --- a/app/index.js +++ b/app/index.js @@ -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. diff --git a/package.json b/package.json index b40326088..4730b05e0 100644 --- a/package.json +++ b/package.json @@ -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" ] -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index a5cefce5e..2d628e183 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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==