Skip to content

[BUG]: Critical bidirectional update failure in Dgraph v24.1.1-test1 with GraphQL @hasInverse #9338

@asta331

Description

@asta331

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

  1. Apply the above GraphQL schema in a Dgraph Cloud environment.
  2. Create an instance of type A that is initially connected to a specific instance of type B via the edge_to_b field.
  3. Use the updateA mutation to update A.edge_to_b so that it points to a different instance of type B.
  4. Query both A.edge_to_b and B.edge_to_a after the mutation.
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions