Grandchild is not attached to Child when using addType

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

1 Like

This brings my production to a halt until this is resolved. I am using Dgraph for deeply nested data and sometimes that data needs to be added in a single transaction. For instance, Adding a new contact with a new address that is in a new city, that is in a new state, that has a new zip code… This breaks that whole process down and does not connect all of the pieces together. Thanks @core-devs for looking into this and getting it fixed.

I was able to reproduce this and am looking into a fix for this. This is a bug that is peculiar to deep nested mutations with types having @id fields.

2 Likes

Update - Still looking at this. Shall have a fix and a PR by early next week.

A fix for this issue was merged to master and would be part of the 20.07.1 release.

3 Likes

We are using Slash. I’m not sure how to tell what version Slash is running though.

Hey @pbassham,
have a look at the Slash release strategy here: Dgraph now has a Slash branch
Will update you when 20.07.1 gets released and is in Slash.

Thanks

2 Likes

This fix should be available in your Slash GraphQL instance now.

Update - @pbassham sorry for the wrong info above. I confirmed with the Slash team and looks like the fix is not live yet on Slash. It should be available with the next release of Slash. You can monitor that at Topics tagged release

1 Like

Thanks for the update that was so timely that it was early.

Also, thanks for the link to be able to track Slash releases. I was just hacking something together yesterday trying to track those more closely, but watching that tag is much better.

This is the PR: fix(GraphQL): Linking of xids for deep mutations (#6172) · dgraph-io/dgraph@806a8df · GitHub