diff --git a/index.js b/index.js index 8581dc2..32b5a74 100644 --- a/index.js +++ b/index.js @@ -36,6 +36,11 @@ const typeDefs = gql` permission: Int } + type RemovedProperty { + id: String! + device: String! + } + interface Vector { id: String! name: String! @@ -127,6 +132,10 @@ const typeDefs = gql` connected: Boolean } + type RemovedDevice { + id: String! + } + type Message { id: String device: Device! @@ -180,6 +189,7 @@ const typeDefs = gql` disconnected: Int newDevice: Device newProperty: Property + removeProperty: RemovedProperty newValue: Vector newMessage: Message } @@ -210,6 +220,7 @@ indi pubsub.publish(["NEW_DEVICE"], { newDevice: device }); }) .on("newProperty", (property) => { + console.log("new props"); if ( property.getType() === Indi.PropertyType.Number || property.getType() === Indi.PropertyType.Switch || @@ -219,6 +230,10 @@ indi pubsub.publish(["NEW_PROPERTY"], { newProperty: property }); } }) + .on("removeProperty", (propname, devname) => { + console.log("remove props"); + pubsub.publish(["REMOVE_PROPERTY"], { removeProperty: { id: propname, device: devname } }); + }) .on("newNumber", (n) => { pubsub.publish(["NEW_VALUE"], { newValue: n }); }) @@ -342,6 +357,9 @@ const resolvers = { newProperty: { subscribe: () => pubsub.asyncIterator(["NEW_PROPERTY"]), }, + removeProperty: { + subscribe: () => pubsub.asyncIterator(["REMOVE_PROPERTY"]), + }, newValue: { subscribe: () => pubsub.asyncIterator(["NEW_VALUE"]), },