Virtual Node Development (Graph)
A detailed guide on Virtual Nodes: a technique to group and package multiple functional Nodes into a single reusable Node, which can be exported and shared via NPM.
What is a Virtual Node?
A Virtual Node (also known as a Sub-Workflow) is a solution that abstracts complex logic—consisting of multiple interconnected Nodes—into a single, unified node.
Instead of scripting logic in JavaScript (like a traditional Community Node), you can drag and drop existing Nodes in the nLink Builder to orchestrate a workflow. This workflow is saved as JSON and can be published to the NPM registry exactly like a standard Node.
Standard Directory Structure
Using nlink-community.graphNode as an example, the directory structure is minimal since it doesn't require a JavaScript execution script (execution.js):
nlink-community.graphNode/
├── package.json # NPM configuration & nLink package identification
└── definition.json # The core file containing Node definitions and Workflow Data (Graph Data)Exploring `definition.json` Elements
Inside the definition.json of a Virtual Node, there are two primary components: schema (UI definition) and graph_data (workflow logic).
- The "schema" Block
Contains identity information identical to regular nodes. Thepropertiesarray acts as the input variables for your workflow."schema": { "name": "nlink-community.graphNode", "displayName": "graphNode", "group": ["community"], "icon": "bi-box", "properties": [ // Define Authentication portals or Workflow Parameters here... ] } - The "graph_data" Block
This section defines your orchestration structure, detailing the internal nodes (nodes) and their respective connections (connections)."graph_data": { "nodes": [ { "type": "nlink-virtual.input", "name": "Virtual Node Input" }, { "type": "nlink-base.httpRequest", "name": "HTTP Request 1" }, { "type": "nlink-base.httpRequest", "name": "HTTP Request 2" }, { "type": "nlink-base.merge", "name": "Merge" }, { "type": "nlink-virtual.output", "name": "Virtual Node Output" } ], "connections": { ... } } - Virtual Input & Output (The Core Elements)
Withingraph_data, there must always exist two special routing nodes:nlink-virtual.inputandnlink-virtual.output. These act as gateways, receiving data from the Virtual Node's external inputs and returning execution results from the internal logic loop.
Publishing Process (NPM)
Once you have exported the JSON file containing the graph_data from the nLink Editor, the publishing process is identical to that of a Community Node:
# 1. Initialize an accurate package.json
npm init
# 2. Login and push it to the public NPM registry
npm publish --access public