Describe the bug
In a Dgraph Cloud environment using Dgraph version v24.1.1-test1, the following GraphQL schema exhibits an issue with bidirectional updates using the @hasInverse directive:
type A {
id: ID
edge_to_b: [B] @hasInverse(field: "edge_to_a")
}
type B {
id: ID
edge_to_a: A
}
When using an updateA mutation to change the connections in A.edge_to_b to point to a different B instance, the bidirectional update does not fully propagate. Specifically, while B.edge_to_a reflects the new connection, A.edge_to_b remains unchanged and continues to point to the original B.
To Reproduce
- Apply the above GraphQL schema in a Dgraph Cloud environment.
- Create an instance of type
A that is initially connected to a specific instance of type B via the edge_to_b field.
- Use the
updateA mutation to update A.edge_to_b so that it points to a different instance of type B.
- Query both
A.edge_to_b and B.edge_to_a after the mutation.
- Observe that while
B.edge_to_a reflects the new connection, A.edge_to_b still shows the original connection.
Expected behavior
When the updateA mutation modifies A.edge_to_b, both sides of the relationship should be updated consistently. Both A.edge_to_b and B.edge_to_a should reflect the new connection as specified by the mutation.
Environment
- OS: Dgraph Cloud
- Language: GraphQL (Dgraph)
- Version: Dgraph v24.1.1-test1 (Issue observed in this version; exact version when the issue first occurred is unknown)
Additional context
This issue appears to be related to how Dgraph handles bidirectional updates with the @hasInverse directive. The mutation correctly updates the B.edge_to_a field but fails to update A.edge_to_b as expected. Notably, this schema previously worked correctly in earlier versions, and it is unclear from which version the problem started to occur. Further investigation or review of the Dgraph issue tracker may be required to determine if this is a known bug or if a workaround exists.
Describe the bug
In a Dgraph Cloud environment using Dgraph version v24.1.1-test1, the following GraphQL schema exhibits an issue with bidirectional updates using the
@hasInversedirective:type A {
id: ID
edge_to_b: [B] @hasInverse(field: "edge_to_a")
}
type B {
id: ID
edge_to_a: A
}
When using an
updateAmutation to change the connections inA.edge_to_bto point to a differentBinstance, the bidirectional update does not fully propagate. Specifically, whileB.edge_to_areflects the new connection,A.edge_to_bremains unchanged and continues to point to the originalB.To Reproduce
Athat is initially connected to a specific instance of typeBvia theedge_to_bfield.updateAmutation to updateA.edge_to_bso that it points to a different instance of typeB.A.edge_to_bandB.edge_to_aafter the mutation.B.edge_to_areflects the new connection,A.edge_to_bstill shows the original connection.Expected behavior
When the
updateAmutation modifiesA.edge_to_b, both sides of the relationship should be updated consistently. BothA.edge_to_bandB.edge_to_ashould reflect the new connection as specified by the mutation.Environment
Additional context
This issue appears to be related to how Dgraph handles bidirectional updates with the
@hasInversedirective. The mutation correctly updates theB.edge_to_afield but fails to updateA.edge_to_bas expected. Notably, this schema previously worked correctly in earlier versions, and it is unclear from which version the problem started to occur. Further investigation or review of the Dgraph issue tracker may be required to determine if this is a known bug or if a workaround exists.