Skip to content

Docs(GraphQL): document inverse relationships in Dgraph GraphQL#738

Merged
raphael-istari merged 3 commits intomainfrom
matthewmcneely/document-graphql-dql-reverse-edge-differences
Feb 6, 2026
Merged

Docs(GraphQL): document inverse relationships in Dgraph GraphQL#738
raphael-istari merged 3 commits intomainfrom
matthewmcneely/document-graphql-dql-reverse-edge-differences

Conversation

@matthewmcneely
Copy link
Copy Markdown
Collaborator

Added documentation on defining bidirectional relationships in Dgraph GraphQL schemas, detailing two approaches: Dual Predicates and Reverse Index, along with their tradeoffs, usage examples, and migration guidance.

Added documentation on defining bidirectional relationships in Dgraph GraphQL schemas, detailing two approaches: Dual Predicates and Reverse Index, along with their tradeoffs, usage examples, and migration guidance.
Copy link
Copy Markdown
Contributor

@mlwelles mlwelles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is an very helpful addition to the docs.

When I was working on a Postgres schema conversion for a POC, it wasn't clear to me which to use when I converted the DQL schema I first created to a 'canonical' GraphQL representation. I did the first pass using @dgraph(pred: "~...") but then worried I by doing so I was leaning on legacy syntax and switched to @hasInverse.

IIRC I even asked opus to search the docs to explain the difference and what the preferred for was, and it wasn't able to provide a clear answer, besides suggesting @hasInverse was newer and therefore more likely to be idiomatic.

I didn't have any idea by doing so I was committing to having the GraphQL API layer be solely responsible for maintaining consistency, and that any DQL mutations I applied after would have to explicitly apply the reverse relationship as a separate predicate.

Being a little more careful I might have noticed lack of reverse relationships in the DQL schema created from the GraphQL -- I even saved the json of the DQL schema generated from the GraphQL as a fixture and used it in a comparison test -- but it didn't occur to me that it would be something I should check.

@raphael-istari raphael-istari merged commit f39b590 into main Feb 6, 2026
@raphael-istari raphael-istari deleted the matthewmcneely/document-graphql-dql-reverse-edge-differences branch February 6, 2026 05:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants