maaft
February 19, 2021, 12:59pm
1
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 :
Don’t allow a reference to foo when bar is added as a child of foo
or
Don’t throw this error and ignore the ID when it’s set to the same ID as the parent
rajas
(Rajas Vanjape)
February 20, 2021, 5:49am
2
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.
maaft:
Solutions :
Don’t allow a reference to foo when bar is added as a child of foo
or
Don’t throw this error and ignore the ID when it’s set to the same ID as the parent
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.
maaft
February 20, 2021, 6:56pm
3
Yes, I know that this is not necessary. Just stumbled across this by mistake.
I guess solution 2 would be fitting. Thanks!
rajas
(Rajas Vanjape)
February 23, 2021, 11:46am
5
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