Skip to content

@ReadOnly: a field that is loaded and never written

@GraphView
data class IssueOverview(
@Root val issue: Issue,
@GraphRelationship(type = "ASSIGNED_TO") val assignedTo: List<Person>, // written on save
@ReadOnly @GraphRelationship(type = "REVIEWED_BY") val reviewers: List<Person>, // loaded only
)

Every save skips a @ReadOnly field: no relationship is written for it and the nodes it holds are not saved. Naming it in Replace is an error, and Replace.all() leaves it alone.

Three kinds of field are read-only whether or not they are declared so, because none of them names a single relationship a save could write:

  • a @GraphPath field;
  • a @Count or @Aggregate field;
  • a list of fragments read over several hops (maxDepth above 1). A view nested in itself is not one: each level of it is one relationship from the level above, and it is saved.

@ReadOnly on one of them is allowed and changes nothing. To write along a path, use edges.relate, Cypher, or a view rooted where the hop starts.