Residual Issue Linking Grandchild in mutation with custom ids

Continuing the discussion from Grandchild is not attached to Child when using addType:

@abhimanyusinghgaur tagging you as you resolved the above issue.

@pbassham tagging you as you found this bug.

We are still having a residual side effect from this. I have simplified our schema and input to make a reproducable error. You can even run the separate queries/mutations from the code below if you copy/paste it into a new Slash instance:

Schema:

type Gift {
  myid: String! @id
  constituent: Contact! @hasInverse(field: hasGifts)
  gift_splits: [Splits] @hasInverse(field: fromGift)
}
type Splits {
  myid: String! @id
  fromGift: Gift
  fund_id: Fund
}
type Fund {
  myid: String! @id
  hasSplits: [Splits]  @hasInverse(field: fund_id)
}
type Contact {
  myid: String! @id
  hasGifts: [Gift]
}

Mutations/Query:

mutation addData {
  addGift(
    input: [
      {
        myid:"10311",
        constituent:{myid:"6752"},
        gift_splits:[{myid:"13213",fund_id:{myid:"23"}}],
      },{
        myid:"13555",
        constituent:{myid:"6752"},
        gift_splits:[{myid:"19748",fund_id:{myid:"23"}}],
      },{
        myid:"14908",
        constituent:{myid:"6752"},
        gift_splits:[{myid:"22456",fund_id:{myid:"23"}}],
      },{
        myid:"23138",
        constituent:{myid:"6752"},
        gift_splits:[{myid:"43653",fund_id:{myid:"23"}}],
      },{
        myid:"24084",
        constituent:{myid:"6752"},
        gift_splits:[{myid:"45507",fund_id:{myid:"23"}}],
      },{
        myid:"9407",
        constituent:{myid:"3605"},
        gift_splits:[{myid:"11373",
        fund_id:{myid:"15"}}],
      },{
        myid:"14661",
        constituent:{myid:"3605"},
        gift_splits:[{myid:"22023",fund_id:{myid:"15"}}],
      },{
        myid:"2350",
        constituent:{myid:"4535"},
        gift_splits:[{myid:"2350",fund_id:{myid:"40"}}],
      },{
        myid:"2352",
        constituent:{myid:"4535"},
        gift_splits:[{myid:"2352",fund_id:{myid:"21"}}],
      },{
        myid:"3688",
        constituent:{myid:"4535"},
        gift_splits:[{myid:"3688",fund_id:{myid:"40"}}],
      },{
        myid:"3689",
        constituent:{myid:"4535"},
        gift_splits:[{myid:"3689",fund_id:{myid:"21"}}],
      },{
        myid:"5960",
        constituent:{myid:"4535"},
        gift_splits:[{myid:"5960",fund_id:{myid:"40"}}],
      },{
        myid:"5962",
        constituent:{myid:"4535"},
        gift_splits:[{myid:"5962",fund_id:{myid:"21"}}],
      },{
        myid:"20164",
        constituent:{myid:"6236"},
        gift_splits:[
          {myid:"31751",fund_id:{myid:"14"}},
          {myid:"31755",fund_id:{myid:"27"}},
          {myid:"31756",fund_id:{myid:"30"}},
          {myid:"31753",fund_id:{myid:"31"}},
          {myid:"31754",fund_id:{myid:"41"}},
          {myid:"31752",fund_id:{myid:"62"}},
          {myid:"31757",fund_id:{myid:"63"}}
        ],
      },{
        myid:"16481",
        constituent:{myid:"8063"},
        gift_splits:[{myid:"24761",fund_id:{myid:"111"}}],
      }]
  ) {
    numUids
    gift {
      myid
      constituent {myid}
      gift_splits {
        fund_id {myid}
      }
    }
  }
}
mutation Reset {
  deleteGift(filter: {}) {
    numUids
  }
  deleteSplits(filter: {}) {
    numUids
  }
  deleteContact(filter: {}) {
    numUids
  }
  deleteFund(filter: {}) {
    numUids
  } 
}
query Read {
    queryGift {
      myid
      constituent {myid}
      gift_splits {
        fund_id {myid}
      }
    }
}

You can run addData mutation to add the data, Reset to clear the data, and Read to read the added data.

The problem is that it is not linking existing funds if they are duplicate (already linked to another). For example fund myId 23, is used multiple times. It is linked only once though and not to any of the other uses.

# snippet of addData response
        {
          "myid": "10311",
          "constituent": {
            "myid": "6752"
          },
          "gift_splits": [
            {
              "fund_id": {
                "myid": "23"
              }
            }
          ]
        },
        {
          "myid": "14661",
          "constituent": {
            "myid": "3605"
          },
          "gift_splits": [
            {
              "fund_id": null # should be { "myid": "23" }
            }
          ]
        },

Thanks for the excellent detailed bug report @amaster507. I have a potential fix in fix(GraphQL): Link xids properly if there are duplicate xids within the same add request. by pawanrawal · Pull Request #6265 · dgraph-io/dgraph · GitHub. We’ll get it reviewed and merged soon if all looks good with it.

1 Like

A fix has been merged to master fix(GraphQL): Link xids properly if there are duplicate xids within the same add request. by pawanrawal · Pull Request #6265 · dgraph-io/dgraph · GitHub and would be part of the next Slash release.

2 Likes