Version: Using Slash
Schema:
type Post {
id: String! @id
content: String
author: Person
comments: [Comment]
}
type Person {
id: String! @id
name: String
}
type Comment {
id: String! @id
message: String
replies: [Comment]
}
Action: Run Mutation:
mutation {
addPost(input: [{
id: "post1",
author: {id: "person1"},
comments: [{
id: "comment1",
replies: [{
id: "reply1"
}]
}]
}]) {
numUids
post {
id
author {
id
}
comments {
id
replies {
id
}
}
}
}
}
Results:
{
"data": {
"addPost": {
"numUids": 1,
"post": [
{
"id": "post1",
"author": {
"id": "person1"
},
"comments": [
{
"id": "comment1",
"replies": []
}
]
}
]
}
},
"extensions": {
"touched_uids": 40,
"tracing": {
"version": 1,
"startTime": "2020-08-04T22:27:10.316918521Z",
"endTime": "2020-08-04T22:27:10.334251698Z",
"duration": 17333185,
"execution": {
"resolvers": [
{
"path": [
"addPost"
],
"parentType": "Mutation",
"fieldName": "addPost",
"returnType": "AddPostPayload",
"startOffset": 142834,
"duration": 17154663,
"dgraph": [
{
"label": "mutation",
"startOffset": 288666,
"duration": 9701402
},
{
"label": "query",
"startOffset": 12587810,
"duration": 4654739
}
]
}
]
}
},
"queryCost": 1
}
}
Looking at the queryComment
results:
{
queryComment {
id
replies {
id
}
}
}
Which gives the following output:
{
"data": {
"queryComment": [
{
"id": "comment1",
"replies": []
},
{
"id": "reply1",
"replies": []
}
]
},
"extensions": {
"touched_uids": 6,
"tracing": {
"version": 1,
"startTime": "2020-08-04T22:32:05.065125192Z",
"endTime": "2020-08-04T22:32:05.066823854Z",
"duration": 1698672,
"execution": {
"resolvers": [
{
"path": [
"queryComment"
],
"parentType": "Query",
"fieldName": "queryComment",
"returnType": "[Comment]",
"startOffset": 115874,
"duration": 1558066,
"dgraph": [
{
"label": "query",
"startOffset": 160027,
"duration": 1474442
}
]
}
]
}
},
"queryCost": 1
}
}
What is wrong?
I see that reply1
was added but it was not link was not made to the Comment.replies
predicate of comment1
I can duplicate this by adding any new node with a new child and new grandchild. I have not tried to duplicate it with an existing child with a new grandchild or vice versa. Also, I am uniquely using id: String @id
and have not tested with regular id: ID
Take it for a spin: https://master-test.us-west-2.aws.cloud.dgraph.io/graphql