fix: makes array updates work again

This commit is contained in:
Alexis Tyler
2020-05-10 17:16:00 +09:30
parent ddd853223d
commit a3cd68cbd7
4 changed files with 1116 additions and 1278 deletions

2346
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,6 +12,7 @@ import GraphQLJSON from 'graphql-type-json';
import GraphQLLong from 'graphql-type-long';
import GraphQLUUID from 'graphql-type-uuid';
import { run, publish } from '../../run';
import { cache } from '../../cache';
import { hasSubscribedToChannel, canPublishToChannel } from '../../ws';
const { pluginManager, pubsub, utils, log, bus, errors, states } = core;
@@ -19,8 +20,8 @@ const { ensurePermission } = utils;
const { usersState } = states;
const { AppError, PluginError } = errors;
// Update array values when disks change
bus.on('disks', async () => {
// Update array values when slots change
bus.on('slots', async () => {
// @todo: Create a system user for this
const user = usersState.findOne({ name: 'root' });
@@ -93,7 +94,15 @@ const createSubscription = (channel, resource?) => ({
export const resolvers = {
Query: {
info: () => ({}),
vms: () => ({})
vms: () => ({}),
server(name: string) {
// Single server
// return cache.get();
},
servers() {
// All servers
return cache.data;
}
},
Subscription: {
apikeys: {
@@ -125,6 +134,9 @@ export const resolvers = {
services: {
...createSubscription('services')
},
servers: {
...createSubscription('servers')
},
shares: {
...createSubscription('shares')
},

View File

@@ -0,0 +1,28 @@
type Query {
server(name: String!): Server @func(module: "servers/name/get-server")
servers: [Server] @func(module: "getServers")
}
type ServerSubscription {
mutation: UpdateOnlyMutationType!
node: Server!
}
type ServersSubscription {
mutation: UpdateOnlyMutationType!
node: [Server!]
}
type Subscription {
server(name: String!): ServerSubscription
servers: ServersSubscription
}
type Status = 'Online' | 'Offline';
type Server {
name: String!
status: Status!
wanIp: String!
localUrl: String!
remoteUrl: String!
}

View File

@@ -14,7 +14,7 @@ type ServicesSubscription {
}
type Subscription {
service(id: ID!): ServiceSubscription
service(name: String!): ServiceSubscription
services: ServicesSubscription
}