Skip to main content
Version: Next

SerializationContext <T>

Helper that allows to keep track of where we are currently at when serializing complex entity graph with cycles. Before we process a property, we call visit that checks if it is not a cycle path (but allows to pass cycles that are defined in populate hint). If not, we proceed and call leave afterwards.

Index

Constructors

constructor

Properties

readonlypath

path: [EntityName, string][] = []

readonlyvisited

visited: Set<Partial<any>> = ...

Methods

close

  • close(): void
  • Cleans up the serialization context by removing root references from all tracked entities.


    Returns void

isExcluded

  • isExcluded(entityName, prop): boolean
  • Checks whether a property is excluded from serialization via the exclude list.


    Parameters

    Returns boolean

isMarkedAsPopulated

  • isMarkedAsPopulated(entityName, prop): boolean
  • Checks whether a property is explicitly listed in the populate hints for the current path.


    Parameters

    Returns boolean

isPartiallyLoaded

  • isPartiallyLoaded(entityName, prop): boolean
  • Checks whether a property is included in the partial fields selection for the current path.


    Parameters

    Returns boolean

leave

  • leave(entityName, prop): void
  • Removes the last entry from the visit path after processing a property.


    Parameters

    Returns void

visit

  • visit(entityName, prop): boolean
  • Returns true when there is a cycle detected.


    Parameters

    Returns boolean

staticpropagate

  • propagate(root, entity, isVisible): void
  • Propagates the context to the entity and its direct relations, so nested serialization calls pick it up. Runs for every serialized entity, so the context spreads along the serialized path instead of the whole graph.


    Parameters

    Returns void