Skip to content

Custom Edges

The Graph comes with a set of natural, built-in edges between nodes. Additionally, Actor Extensions can define custom relations between nodes. However, there are cases where you want to create an edge based on an implicit relationship, or based on an existing system field.

One such case might be to create a relationship between orderLine’s productNumber and a sku. This is a common practice for businesses that sell single-sku products.

Any field including custom fields can be used by custom edges, except dynamic fields. If you have a dynamic field that you want to use as the relationship key between nodes, define it as a custom field first.

Configuring a Custom Edge

Edges are configured in the Registry using keys as follows:

graph/<node>/fields/<field key>

The value should be an object with the following properties:

PropertyDescription

field

The field of the current node to use as key for the relationship.

relationSet

The name of the related set. Node that this should not be the node name but the name of the set containing the nodes you want to link to.

relationField

optional

The field on the related node to use as key for the relationship. If not specified, it will be assumed to be the same name as field above.

cardinality

Indicates if the related node can be many or is expected to be a single node. This affects how results are returned in queries.

Possible values:

  • many
  • single

Two-way Edges

Note that edges in Hantera are one-way by nature. In order to make a two-way edge, simply define the oppsite edge on the related node.

Troubleshooting

After defining a custom edge, it should show up in the graph pretty much immediately. If you can’t see it, check signals to see it has reported any error:

Terminal window
h_ manage signals

Example

Here’s an example manifest for defining a custom edge:

uri: /resources/registry/graph/orderLine/edges/sku
spec:
field: 'productNumber'
relatedSet: 'skus'
relatedField: 'skuNumber'
cardinality: 'single'
---
uri: /resources/registry/graph/sku/edges/orderLines
spec:
field: 'skuNumber'
relatedSet: 'orderLiones'
relatedField: 'productNumber'
cardinality: 'many'