Just trying to identify where the breakdown is. Is the relationship not being removed like it should, or is the problem with the query? I probably should run this to see it for myself instead of just keyboard warrior here trying to hash this out.
Thank you for the suggestion. Not really looking for a work around, just raising a bug and wondering whether I should wait for a fix or work around in my codebase (which will mean removing the work around once it’s fixed )
It does work, but it’s surely a workaround I asked Dgraph to delete that node, which should include removing all edges to that node as well – it shouldn’t be a huge change to the GraphQL query generator to filter out results with no dgraph.type (which is a good indication that they’ve been deleted)
I think you’re talking about two different things. The @cascade is not a workaround, but does solve your query problem. What you actually want, is a cascade on delete that just removes the connection(s).
This is a feature request that I made a while back. Hopefully we will see this one day, as this is how SQL handles the situation:
Basically what you are suggesting is that someone using the GraphQL endpoint should add @cascade to any edge query if the want to be able to delete nodes. Do I understand that correctly?
I totally understand the why of the issue, I’m just saying that any user that is not familiar with the way Dgraph (not just the GraphQL endpoint) works will think this is a bug.
Since these information-less edges serve no purpose to the GraphQL endpoint, I’m suggesting that they should be filtered out by the endpoint.
Since there are no Github issues for Dgraph any more all I can do is start a thread about it where we discuss workarounds
With the @cascade directive, nodes that don’t have all fields specified in the query are removed. This can be useful in cases where some filter was applied and some nodes might not have all the listed fields.
So this is correct. The real bug here is that the “informationless edges,” or “Non-nullable fields” are allowed to exist in the first place. There are only two possible fixes for this:
Don’t allow them to be deleted if one edge requires it to exist (Dgraph needs to return an error in this case)
Cascade delete both edges (if my @reference directive is added) - not to be confused with @cascade directive, completely different things…
The other option is what is currently happening: allowing a node with non-nullable fields to exist.
We hate this option, as it opens up a world of bad schema validation, potential query errors, etc.
@cascade is really just a filter. We don’t want unnecessary filters as our default way of querying.