[Bug] Not sure how to name this bug - please help out

Found on branch releases/v20.11 commit hash: e1ee8595ec0d6d8e91a9292a4eb28738f1fbdd6c

schema

type Foo {
  id: String! @id
  bar: Bar! @hasInverse(field: foo)
}

type Bar {
  id: String! @id
  foo: Foo!
}

mutation

mutation {
  addFoo(input: [
    {
      id: "1231"
      bar: {
        id: "12344"
        foo: {id: "1231"}
      }
    }
  ]) {
    numUids
  }
}

Error: "message": "couldn't rewrite mutation addFoo because failed to rewrite mutation payload because duplicate XID found: 1231"

Solutions:

  1. Don’t allow a reference to foo when bar is added as a child of foo
    or
  2. Don’t throw this error and ignore the ID when it’s set to the same ID as the parent

I am able to reproduce this on latest master .

Ideally, as foo is an inverse field of bar, there is no need to explicitly reference it.

The mutation will work perfectly fine and do what is expected if foo : { id: "1231"} is not supplied as a field to bar object.

We can consider solution 2 in which the inverse field will be ignored (foo in this case) will be ignored no matter what is supplied, the same parent or any other parent.

Yes, I know that this is not necessary. Just stumbled across this by mistake.

I guess solution 2 would be fitting. Thanks!

This has been fixed in master with the merging of PR . The fix simply ignores any inverse field (same or any other parent) provided with the mutation.

1 Like