Delete Node and pointing Edge in GraphQL

Hello everyone,
I would like to know what is the “best” way to delete the Node and the edge pointing to that node using GraphQL mutation.

Here is an example of the schema I use:

type Entity @withSubscription {
    id: ID!
    name: String! @id @search(by: [exact, regexp])
    source: String
    color: String
    mesh: String
    sensors: [Sensor]
    parent: Entity
    has: [Entity] @hasInverse(field: "parent")
}

type Sensor @withSubscription {
    id: ID!
    name: String! @id @search(by: [exact, regexp])
    value: Float @search
    timestamp: DateTime
}

For example, let’s say that I have node of type Entity named Car, also there is an node of type Sensor named TemperatureSensor and I’ve connected those two nodes. If I want to delete the TemperatureSensor using this mutation:

mutation MyMutation {
  deleteSensor(filter: {name: {eq: "TemperatureSensor"}}) @cascade {msg}
}

I’ll get the response that the node is deleted, but in the Ratel UI, relationship is still visible, and the node (only ID property is visible, others are removed).

So what is the best way (using single mutation) to delete the node and pointing relationship using GraphQL?

Thanks in advance!

1 Like