graphql
graphql copied to clipboard
Disconnect for undirected relationships doesn't work from both sides
Describe the bug Disconnecting undirected relationships only works from one side
Type definitions
type Item {
name: String
relatesTo: [Item!]! @relationship(type: "RELATES_TO", direction: OUT, queryDirection: DEFAULT_UNDIRECTED)
}
To Reproduce Steps to reproduce the behavior:
- Run a server with the following code...
- Execute the following Mutation...
mutation {
createItems(input: {
name: "A",
relatesTo: {
create: {
node: {
name: "B"
}
}
}
}) {
items {
name
relatesTo {
name
}
}
}
}
- Then run the following Query... The relationship was created successfully. It is possible to query the relationship from both sides.
query {
items {
name
relatesTo {
name
relatesTo {
name
}
}
}
}
Result:
{
"data": {
"items": [
{
"name": "A",
"relatesTo": [
{
"name": "B",
"relatesTo": [
{
"name": "A"
}
]
}
]
},
{
"name": "B",
"relatesTo": [
{
"name": "A",
"relatesTo": [
{
"name": "B"
}
]
}
]
}
]
}
}
- Run the following mutations: (1) Works fine: The relationship has been deleted
mutation {
updateItems(
where: {
name: "A",
},
disconnect: {
relatesTo: {
where: {
node: {
name: "B"
}
}
}
}
) {
items {
name
relatesTo {
name
relatesTo {
name
}
}
}
}
}
(2) Doesn't work: The relationship persists after the mutation. Nothing has happened.
mutation {
updateItems(
where: {
name: "B",
},
disconnect: {
relatesTo: {
where: {
node: {
name: "A"
}
}
}
}
) {
items {
name
relatesTo {
name
relatesTo {
name
}
}
}
}
}
Expected behavior As with the query, a mutation should also work in both directions if the DEFAULT_UNDIRECTED or UNDIRECTED_ONLY option is activated.
Many thanks for raising this bug report @AccsoSG. :bug: We will now attempt to reproduce the bug based on the steps you have provided.
Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:
- Type definitions
- Resolvers
- Query and/or Mutation (or multiple) needed to reproduce
If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.
Thanks again! :pray:
Hi, @AccsoSG,
At this moment we do not provide a way to disconnect in an undirected way.
Could be counter-intuitive but the argument queryDirection
is used only to evaluate the Selection Set.
Although, it's possible that in the future this behavior could be included.
Hi @MacondoExpress, Thanks for the answer
Is there currently a workaround to do this in a single mutation?
As far as I'm aware, I believe not, unfortunately!
@MacondoExpress I've noticed that the queryDirection value is not used in the where clause as well. This to me is pretty misleading as the direction specified in the property is retained in the where clause, but not in the selection set. Is this behavior also known?
@jrsperry Yes, is the expected behavior.