Skip to content

@eightkk/vue-weave / core / checkGraphConnection

Function: checkGraphConnection() ​

checkGraphConnection(nodes, edges, rules, connection, replacingEdgeId?): GraphConnectionCheck

Defined in: src/core/graphPortRules.ts:293

Checks one proposed connection against the rules and the current edges. Returns { ok: true }, or a rejection with a code (unknown-node, unknown-port, direction, type-mismatch or limit-reached), a readable reason and the endpoint that broke the rule; the checks run in that order and the first broken rule is reported. With replacingEdgeId (a reconnection), that edge is left out of the connection counts, so a port with maxConnections: 1 can move its own edge. An unknown replacingEdgeId throws an Error; see createGraphConnectionChecker for the other errors. To check many proposals over the same data, build a checker once.

Parameters ​

nodes ​

readonly IdentifiedNode[]

edges ​

readonly GraphEdge<unknown>[]

rules ​

GraphPortRules

connection ​

GraphConnection

replacingEdgeId? ​

string

Returns ​

GraphConnectionCheck

Released under the MIT License.