Documentation
¶
Overview ¶
Package relation validates the relation graph declared across a bounded context's models: target/inverse resolution and kind compatibility, per-kind query command/cardinality requirements, and scope parameter/type/name-collision compatibility. It is the home for spec 001's previously-reserved diagnostics stages 7 ("relation graph") and 8 ("scope compatibility") — see specs/002-relations-lazy-eager-loading/ data-model.md and contracts/relation-diagnostics-contract.md. Decoding RelationConfiguration/ScopeConfiguration itself lives in internal/config, alongside the rest of the plugin's `options` schema; this package only validates the already-decoded shape against other models and real sqlc query metadata.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateScopes ¶
func ValidateScopes(rel config.RelationConfiguration, g Graph, queries []*pb.Query, path, contextName, modelName string) ([]diagnostics.Diagnostic, map[string]*pb.Query)
ValidateScopes validates rel's `parameters` bindings and `scopes` against g's already-matched queries and req's full query list (data-model.md "Relation Graph Validation" stage 8; FR-009 through FR-011). It also returns each query-variant scope's resolved query (scope name -> query), so internal/plan doesn't need to re-resolve query names it already validated here.
Types ¶
type Graph ¶
type Graph struct {
TargetModel *config.ModelConfiguration // pointer into the owning context's Models
Inverse *config.RelationConfiguration // pointer into TargetModel.Relations; nil if unset
LazyQuery *pb.Query
EagerQuery *pb.Query // nil unless configured
AttachQuery *pb.Query // nil unless configured (standalone attach_query)
DetachQuery *pb.Query // nil unless configured (standalone detach_query)
SyncList *pb.Query // nil unless sync_queries configured
SyncAttach *pb.Query // nil unless sync_queries configured
SyncDetach *pb.Query // nil unless sync_queries configured
}
Graph is stage 7's resolved output for one relation: the matched sqlc queries and the target/inverse relation's position within the context, ready for internal/plan to wire into ResolvedRelation pointers (data-model.md "Relation Graph Validation").
func ValidateGraph ¶
func ValidateGraph(ctx config.BoundedContext, rel config.RelationConfiguration, queries []*pb.Query, path, contextName, modelName string) (Graph, []diagnostics.Diagnostic)
ValidateGraph validates rel's target/inverse resolution and its configured queries' command/cardinality against ctx's other models and req's query metadata (data-model.md "Relation Graph Validation" stage 7). Target/inverse resolution is same-context only (research.md Assumptions): an unresolved target is also how a cross-context relation attempt is rejected, since there is no cross-context lookup to fall back to.