feat: pass entity to get projection ids #43
Merged
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.
Consider the following graph:
It has a tree-like structure that you will probably find in most bounded contexts in some shape or form. As of #29 you can represent each of these nodes as an entity in a single transaction repository.
If each branch node's entity has the
Id
of every ancestor node's entity, this change allows you to easily build a projection of the entire tree.When the
ProjectionSnapshotTransactionSubscriber
runs, it will not have to run queries to get the ancestor node's entity ids.. you can just check what kind of object the entity is and pull the appropriate property.The following partial code could be used to map all of these entities to a single projection.
Note
I recommend against storing the entire data model in one repository - you should probably stick to a repository per bounded context - but there is no reason a bounded context must only own a single entity, and therefore there is no reason the transaction repository must only contain a single entity type! When it comes to APIs for accessing the graph of data - obviously GraphQL seems like a great idea, and the concept of schema stitching and linking seems very promising.