From ade0e65bcd02a0fcd9eca99fc96897aff81c440d Mon Sep 17 00:00:00 2001 From: Alexis Tyler Date: Sat, 17 Aug 2019 15:52:50 +0930 Subject: [PATCH] remove welcome subscription and start adding subscriptions for queries Signed-off-by: Alexis Tyler --- app/graphql/index.js | 9 --------- app/graphql/schema/resolvers.js | 3 --- app/graphql/schema/types/array/array.graphql | 9 +++++++++ app/graphql/schema/types/array/parity.graphql | 9 +++++++++ .../schema/types/docker/container.graphql | 16 +++++++++++++++- app/graphql/schema/types/docker/network.graphql | 14 ++++++++++++++ .../schema/types/services/service.graphql | 12 +++++++++++- app/graphql/schema/types/vars/vars.graphql | 9 +++++++++ 8 files changed, 67 insertions(+), 14 deletions(-) diff --git a/app/graphql/index.js b/app/graphql/index.js index f9ac0d635..56db71de5 100644 --- a/app/graphql/index.js +++ b/app/graphql/index.js @@ -61,25 +61,16 @@ module.exports = function ( DELETED } - """ - This can only be updated. - """ enum UpdateOnlyMutationType { UPDATED } - type WelcomeSubscription { - mutation: MutationType! - node: Welcome! - } - type PingSubscription { mutation: MutationType! node: String! } type Subscription { - welcome: WelcomeSubscription! ping: PingSubscription! } `]; diff --git a/app/graphql/schema/resolvers.js b/app/graphql/schema/resolvers.js index 5880297fe..dc9a9a032 100644 --- a/app/graphql/schema/resolvers.js +++ b/app/graphql/schema/resolvers.js @@ -35,9 +35,6 @@ module.exports = function ($injector, GraphQLJSON, GraphQLLong, GraphQLUUID, pub return pubsub.asyncIterator('ping'); } }, - welcome: { - subscribe: () => pubsub.asyncIterator('welcome') - }, services: { subscribe: () => pubsub.asyncIterator('services') }, diff --git a/app/graphql/schema/types/array/array.graphql b/app/graphql/schema/types/array/array.graphql index 42b5ac264..e6f884cd0 100644 --- a/app/graphql/schema/types/array/array.graphql +++ b/app/graphql/schema/types/array/array.graphql @@ -15,6 +15,15 @@ type Mutation { removeDiskFromArray(input: arrayDiskInput): Array @func(module: "array/add-disk") } +type ArraySubscription { + mutation: UpdateOnlyMutationType! + node: Array! +} + +type Subscription { + array: ArraySubscription +} + input arrayDiskInput { """Disk ID""" id: String! diff --git a/app/graphql/schema/types/array/parity.graphql b/app/graphql/schema/types/array/parity.graphql index 91ee450a9..c400bb817 100644 --- a/app/graphql/schema/types/array/parity.graphql +++ b/app/graphql/schema/types/array/parity.graphql @@ -13,6 +13,15 @@ type Mutation { cancelParityCheck: JSON @func(module: "array/update-parity-check", data: { state: "cancel" }) } +type ParityHistorySubscription { + mutation: MutationType! + node: ParityCheck! +} + +type Subscription { + parityHistory: ParityHistorySubscription +} + type ParityCheck { date: String! duration: Int! diff --git a/app/graphql/schema/types/docker/container.graphql b/app/graphql/schema/types/docker/container.graphql index 8dc433f29..e8da93d4a 100644 --- a/app/graphql/schema/types/docker/container.graphql +++ b/app/graphql/schema/types/docker/container.graphql @@ -1,10 +1,24 @@ type Query { """Docker container""" - dockerContainer(id: String!): DockerContainer! @func(module: "docker/get-container") + dockerContainer(id: ID!): DockerContainer! @func(module: "docker/get-container") """All Docker containers""" dockerContainers(all: Boolean): [DockerContainer]! @func(module: "docker/get-containers") } +type DockerContainerSubscription { + mutation: MutationType! + node: DockerContainer! +} +type DockerContainersSubscription { + mutation: MutationType! + node: [DockerContainer]! +} + +type Subscription { + dockerContainer(id: ID!): DockerContainerSubscription + dockerContainers: DockerContainersSubscription +} + enum ContainerPortType { tcp udp diff --git a/app/graphql/schema/types/docker/network.graphql b/app/graphql/schema/types/docker/network.graphql index 59ba4ba9a..82300a2b6 100644 --- a/app/graphql/schema/types/docker/network.graphql +++ b/app/graphql/schema/types/docker/network.graphql @@ -5,6 +5,20 @@ type Query { dockerNetworks(all: Boolean): [DockerNetwork]! @func(module: "docker/get-networks") } +type DockerNetworkSubscription { + mutation: MutationType! + node: DockerNetwork! +} +type DockerNetworksSubscription { + mutation: MutationType! + node: [DockerNetwork]! +} + +type Subscription { + dockerNetwork(id: ID!): DockerNetworkSubscription + dockerNetworks: DockerNetworksSubscription +} + type DockerNetwork { name: String id: String diff --git a/app/graphql/schema/types/services/service.graphql b/app/graphql/schema/types/services/service.graphql index 699f94327..b82d7c3f4 100644 --- a/app/graphql/schema/types/services/service.graphql +++ b/app/graphql/schema/types/services/service.graphql @@ -3,8 +3,18 @@ type Query { services: [Service] @func(module: "get-services") } +type ServiceSubscription { + mutation: UpdateOnlyMutationType! + node: Service! +} +type ServicesSubscription { + mutation: UpdateOnlyMutationType! + node: [Service]! +} + type Subscription { - services: [Service] + service(id: ID!): ServiceSubscription + services: ServicesSubscription } type Service { diff --git a/app/graphql/schema/types/vars/vars.graphql b/app/graphql/schema/types/vars/vars.graphql index cf4ad4552..2ae73319e 100644 --- a/app/graphql/schema/types/vars/vars.graphql +++ b/app/graphql/schema/types/vars/vars.graphql @@ -2,6 +2,15 @@ type Query { vars: Vars @func(module: "get-vars") } +type VarsSubscription { + mutation: UpdateOnlyMutationType! + node: Vars! +} + +type Subscription { + vars(id: ID!): VarsSubscription +} + type Vars { """Unraid version""" version: String