Documentation
¶
Overview ¶
Package population owns schema-driven relationship population traversal.
Population paths are authored field paths, not runtime array indexes. One path therefore applies to every matching row in an array and every matching block instance. Keeping this traversal shared prevents adapters from disagreeing about nested or localized relationship shapes.
Index ¶
- Constants
- func DepthPopulations(collection schema.Collection, depth int) []query.Population
- func FieldAtPath(fields []schema.Field, path query.Path) (schema.Field, bool)
- func MapAtPath(fields []schema.Field, values store.Values, path query.Path, ...) (mapped store.Values, matched bool)
- func MapPopulatedDocuments(fields []schema.Field, values store.Values, allLocales bool, ...) store.Values
- func ReferenceFields(fields []schema.Field) []schema.Field
- func RelationshipDetails(field schema.Field) *schema.RelationshipField
- func VisitAtPath(fields []schema.Field, values store.Values, path query.Path, ...) bool
- type LocaleSelection
Constants ¶
const ( // MaxDepth bounds recursive target expansion. It intentionally matches the // public REST and GraphQL contract. MaxDepth = 5 // MaxExplicitPaths bounds independently requested population branches. A // depth limit alone does not bound a deliberately wide schema or request. MaxExplicitPaths = 64 // MaxExpandedPaths bounds the schema-driven relationship branches visited // while recursively populating targets. MaxExpandedPaths = 256 )
Variables ¶
This section is empty.
Functions ¶
func DepthPopulations ¶
func DepthPopulations(collection schema.Collection, depth int) []query.Population
DepthPopulations expands every relationship/upload field in a target collection to the remaining depth.
func FieldAtPath ¶
FieldAtPath resolves a canonical schema path through groups, arrays, and block discriminators. Repeated runtime rows do not appear in schema paths.
func MapAtPath ¶
func MapAtPath( fields []schema.Field, values store.Values, path query.Path, locales LocaleSelection, transform func(schema.Field, store.Value) store.Value, ) (mapped store.Values, matched bool)
MapAtPath applies transform to every visible runtime occurrence of the terminal schema field. The returned values are always detached. matched is false when the schema path or runtime shape did not contain an occurrence.
func MapPopulatedDocuments ¶
func MapPopulatedDocuments( fields []schema.Field, values store.Values, allLocales bool, transform func(schema.StableID, schema.LocaleCode, store.Document) store.Document, ) store.Values
MapPopulatedDocuments recursively maps already-populated relationship and upload documents in response-shaped values. Single-locale responses have localized fields projected to their scalar/container value; all-locale responses retain locale maps.
func ReferenceFields ¶
ReferenceFields returns every relationship and upload field in stable schema order, including fields beneath groups, arrays, and blocks.
func RelationshipDetails ¶
func RelationshipDetails(field schema.Field) *schema.RelationshipField
RelationshipDetails presents uploads through the same finite target shape as relationships.
Types ¶
type LocaleSelection ¶
type LocaleSelection struct {
All bool
Chain []schema.LocaleCode
}
LocaleSelection identifies the canonical localized values visible to one store request. All maps every configured locale; otherwise Chain is the requested locale followed by its effective fallbacks.