|
@@ -30,7 +30,7 @@ const typeDefs = `
|
|
addresses: [ NetworkAddress ]!
|
|
addresses: [ NetworkAddress ]!
|
|
}
|
|
}
|
|
|
|
|
|
- extend type Query {
|
|
|
|
|
|
+ type System {
|
|
apiVersion: String!
|
|
apiVersion: String!
|
|
hostname: String!
|
|
hostname: String!
|
|
type: String!
|
|
type: String!
|
|
@@ -44,15 +44,15 @@ const typeDefs = `
|
|
cpus: [ CPU! ]!
|
|
cpus: [ CPU! ]!
|
|
networkInterfaces: [ NetworkInterface ]!
|
|
networkInterfaces: [ NetworkInterface ]!
|
|
}
|
|
}
|
|
-
|
|
|
|
- extend type Mutation {
|
|
|
|
- hello: String!
|
|
|
|
|
|
+
|
|
|
|
+ extend type Query {
|
|
|
|
+ system: System!
|
|
}
|
|
}
|
|
`
|
|
`
|
|
|
|
|
|
-const resolvers = {
|
|
|
|
- Query: {
|
|
|
|
- apiVersion: (_) => '0.1',
|
|
|
|
|
|
+function system () {
|
|
|
|
+ return {
|
|
|
|
+ apiVersion: '0.1',
|
|
hostname: os.hostname,
|
|
hostname: os.hostname,
|
|
type: os.type,
|
|
type: os.type,
|
|
platform: os.platform,
|
|
platform: os.platform,
|
|
@@ -63,7 +63,7 @@ const resolvers = {
|
|
totalmem: os.totalmem,
|
|
totalmem: os.totalmem,
|
|
freemem: os.freemem,
|
|
freemem: os.freemem,
|
|
cpus: os.cpus,
|
|
cpus: os.cpus,
|
|
- networkInterfaces: (_) => {
|
|
|
|
|
|
+ networkInterfaces: () => {
|
|
const interfaces = os.networkInterfaces()
|
|
const interfaces = os.networkInterfaces()
|
|
const ifaceArray = []
|
|
const ifaceArray = []
|
|
for (let key in interfaces) {
|
|
for (let key in interfaces) {
|
|
@@ -77,4 +77,10 @@ const resolvers = {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+const resolvers = {
|
|
|
|
+ Query: {
|
|
|
|
+ system
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
module.exports = { typeDefs, resolvers }
|
|
module.exports = { typeDefs, resolvers }
|