Skip to main content

Associations

Associations define relationships between entities in the runtime model. This chapter describes how to query and navigate associations.

The simplest way to access associations is through typed navigation properties. These are generated based on the association roles defined in the Construction Kit.

query {
runtime {
systemCommunicationDataPipeline {
items {
rtId
name
children {
systemCommunicationPipeline {
items {
name
rtId
executedBy {
systemCommunicationAdapter {
items {
rtId
ckTypeId
name
}
}
}
}
}
}
}
}
}
}

This query traverses: DataPipeline → children → Pipeline → executedBy → Adapter

Generic associations query

For more control over association queries, use the generic associations field with filter parameters.

Parameters

ParameterTypeDescription
roleIdStringFilter by association role (e.g., System/ParentChild)
directionGraphDirectionINBOUND, OUTBOUND, or ANY
ckIdStringFilter by target entity type
includeIndirectBooleanInclude transitive associations

Direction

DirectionDescription
OUTBOUNDFrom current entity to related entities (source → target)
INBOUNDFrom related entities to current entity (target → source)
ANYBoth directions
query
{
runtime{
basicTree(rtId: "5fc8fc3d8b2fc75f925e21aa"){
items{
rtId
associations(
roleId: "System/ParentChild"
direction: INBOUND
ckId: "EnergyCommunity/OperatingFacility"
includeIndirect: true
){
items{
rtId
ckTypeId
}
}
}
}
}
}

Returns all Operating Facilities that are direct or indirect parents of the specified Basic Tree.

{
"data": {
"runtime": {
"basicTree": {
"items": [
{
"rtId": "5fc8fc3d8b2fc75f925e21aa",
"associations": {
"items": [
{
"rtId": "693c5b93464d7d9e1396cf1c",
"ckTypeId": "EnergyCommunity/OperatingFacility"
}
]
}
}
]
}
}
}
}

Association definitions

To get detailed information about associations including origin and target:

query getRuntimeEntityAssociationsById(
$rtId: OctoObjectId!
$ckTypeId: String!
$direction: GraphDirection!
$roleId: String
) {
runtime {
runtimeEntities(ckId: $ckTypeId, rtId: $rtId) {
items {
rtId
ckTypeId
associations {
definitions(direction: $direction, roleId: $roleId) {
totalCount
items {
targetRtId
targetCkTypeId
originRtId
originCkTypeId
ckAssociationRoleId
}
}
}
}
}
}
}

Definition fields

FieldDescription
targetRtIdRuntime ID of the target entity
targetCkTypeIdType of the target entity
originRtIdRuntime ID of the origin entity
originCkTypeIdType of the origin entity
ckAssociationRoleIdThe association role ID

Querying associated entity attributes

To get attributes of associated entities, use the targets field:

query {
runtime {
runtimeEntities(ckId: "Basic/Tree", rtId: "5fc8fc3d8b2fc75f925e21aa") {
items {
rtId
associations {
targets(roleId: "System/ParentChild", ckId: "Basic/TreeNode" direction: INBOUND) {
items {
rtId
ckTypeId
# Additional attributes of the target entity can be queried here
}
}
}
}
}
}
}

The above query retrieves all Basic/TreeNode entities that are parents of the specified Basic/Tree.

{
"data": {
"runtime": {
"runtimeEntities": {
"items": [
{
"rtId": "5fc8fc3d8b2fc75f925e21aa",
"associations": {
"targets": {
"items": [
{
"rtId": "5fc8fda18b2fc75f925e21ab",
"ckTypeId": "Basic/TreeNode"
}
]
}
}
}
]
}
}
}
}

Common association roles

Role IDDescription
System/ParentChildHierarchical parent-child relationship
System/OwnershipOwnership relationship

The actual roles available depend on your Construction Kit model configuration.

Best practices

  1. Use typed navigation properties when the relationship structure is known and fixed
  2. Use generic associations query when you need dynamic filtering or traversal
  3. Limit indirect queries - transitive queries on large hierarchies can be expensive
  4. Filter by type when you only need specific entity types from associations
  5. Use pagination on associations with many related entities