Moved from GitHub dgraph/5815
Posted by martaver:
Steps to reproduce the issue (command/config used to run Dgraph).
Using slash graphql, given the schema:
type Player {
id: ID!
title: String! @search(by: [fulltext])
parent: Player
children: [Player] @hasInverse(field: parent)
}
Create a tree of Players, with parent/children edges. Let’s add a root Player with two child Players:
mutation {
addPlayer(input: [
{
title: "root",
children: [
{
title: "A"
},
{
title: "B"
}
]
}
]) {
player {
id
title
children {
id
title
}
}
}
}
Now, I have a UI component in the front-end that can manipulate the tree, and I want to move the Player B to be a child of Player A. It restructured the tree, and gives me a new hierarchy, which I want to push to dgraph.
mutation SetPlayerTree($id: ID!, $children: [PlayerRef]) {
updatePlayer(input: {
filter: {
id: [$id]
}
set: {
children: $children
}
}) {
player {
id
children {
id
children {
id
}
}
}
}
}
With vars, where B has now been moved to be a child of A (replace the ids with whatever you got from your last query):
{
"id": "0x4e22",
"children": [{"id": "0x4e25", "children": [{"id": "0x4e26", "children": []}]}]
}
Expected behaviour and actual result.
I would expect the response to return the hierarchy root -> A -> B
, however it returns root -> [A, B]
:
{
"data": {
"updatePlayer": {
"player": [
{
"id": "0x4e22",
"children": [
{
"id": "0x4e25"
},
{
"id": "0x4e26"
}
]
}
]
}
},
"extensions": {
"touched_uids": 17,
"queryCost": 1
}
}