diff --git a/src/apolloclient.js b/src/apolloclient.js index 8992427..cb71dc1 100644 --- a/src/apolloclient.js +++ b/src/apolloclient.js @@ -140,6 +140,40 @@ client }); }); +const REMOVE_PROPERTY = gql` + subscription delIndiProp { + delIndiProp { + id + device { + id + } + } + } +`; + +client + .subscribe({ + query: REMOVE_PROPERTY, + }) + .subscribe(({ data }) => { + const res = client.readQuery({ + query: GETDEVICE, + variables: { id: data.delIndiProp.device.id }, + }); + client.writeQuery({ + query: GETDEVICE, + variables: { id: res.device.id }, + data: { + device: { + ...res.device, + properties: res.device.properties.filter( + (p) => p.id !== data.delIndiProp.id + ), + }, + }, + }); + }); + const NEW_VALUE = gql` subscription newIndiValue { newIndiValue {