feat: Add WithReverseEdge() option for history-to-entity traversal#83
Merged
lillialjackson merged 5 commits intoflume:mainfrom Feb 4, 2026
Merged
feat: Add WithReverseEdge() option for history-to-entity traversal#83lillialjackson merged 5 commits intoflume:mainfrom
lillialjackson merged 5 commits intoflume:mainfrom
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Contributor
Author
|
@lillialjackson @josue @corvramirez |
lillialjackson
approved these changes
Jan 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@ -0,0 +1,85 @@
Description
Closes #81
Implements
enthistory.WithReverseEdge()option that generates reverse edges from history schemas back to their original entities. When enabled, history schemas include an edge that allows traversal back to the original entity.Changes:
ReverseEdge boolfield toHistoryOptionsstruct ingenerate.goWithReverseEdge()option function ingenerate.gohistoryEdgestruct implementingent.EdgeinterfacereverseEdge()helper to build edge descriptorsReverseEdge boolfield toConfigstruct inextension.goWithReverseEdgeExtension()option function inextension.gohistoryFromMutation.tmplto populate edge FK when reverse edge is enabledinternal/schemast/edge.goto supportImmutableflag in edge AST generationGenerated schema output example:
Motivation and Context
This enables idiomatic ent traversal from history records back to their original entities:
historyRecord.QueryCharacter()- traverse from history to originalclient.CharacterHistory.Query().WithCharacter().All(ctx)- eager load original entitiesPreviously, users had to manually query the original entity using the
reffield. This feature provides first-class edge support for cleaner, more idiomatic code.How Has This Been Tested?
Added 3 integration tests in
_examples/enthistory_basic_test.go:QueryCharacter()returns the correct original entityWithCharacter()works correctlyNotFoundwhen original entity is deletedAll 22 tests pass including the original test suite (delete tracking works correctly).
Screenshots (if appropriate):
N/A
Types of changes
Checklist:
Usage