Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Langgenius Dify SingleNodeRun

From Leeroopedia
Knowledge Sources Dify
Domains Workflow, DAG, Frontend
Last Updated 2026-02-12 00:00 GMT

Overview

Description

The singleNodeRun function and its companion URL generators (getIterationSingleNodeRunUrl and getLoopSingleNodeRunUrl) provide the frontend API layer for executing individual workflow nodes in isolation against the current draft. singleNodeRun issues a POST request to run a specific node with provided parameters, while the URL generators construct the correct API paths for nodes nested within Iteration or Loop containers, which require different routing through the container's execution context.

Usage

  • Call singleNodeRun for standard nodes that are not inside Iteration or Loop containers.
  • Use getIterationSingleNodeRunUrl to construct the URL for nodes inside an Iteration container, then use this URL with the SSE streaming mechanism for execution.
  • Use getLoopSingleNodeRunUrl to construct the URL for nodes inside a Loop container.
  • Both URL generators accept an isChatFlow boolean to handle the URL path difference between advanced-chat flows and standard workflow flows.

Code Reference

Source Location

web/service/workflow.ts, lines 29-39.

Signature

// Execute a single node in the workflow draft
export const singleNodeRun = (
  flowType: FlowType,
  flowId: string,
  nodeId: string,
  params: object,
) => {
  return post(
    `${getFlowPrefix(flowType)}/${flowId}/workflows/draft/nodes/${nodeId}/run`,
    { body: params },
  )
}

// Construct URL for running a node inside an Iteration container
export const getIterationSingleNodeRunUrl = (
  flowType: FlowType,
  isChatFlow: boolean,
  flowId: string,
  nodeId: string,
) => {
  return `${getFlowPrefix(flowType)}/${flowId}/${isChatFlow ? 'advanced-chat/' : ''}workflows/draft/iteration/nodes/${nodeId}/run`
}

// Construct URL for running a node inside a Loop container
export const getLoopSingleNodeRunUrl = (
  flowType: FlowType,
  isChatFlow: boolean,
  flowId: string,
  nodeId: string,
) => {
  return `${getFlowPrefix(flowType)}/${flowId}/${isChatFlow ? 'advanced-chat/' : ''}workflows/draft/loop/nodes/${nodeId}/run`
}

Import

import {
  singleNodeRun,
  getIterationSingleNodeRunUrl,
  getLoopSingleNodeRunUrl,
} from '@/service/workflow'

I/O Contract

Inputs (singleNodeRun)

Parameter Type Required Description
flowType FlowType Yes The type of flow, used to construct the API URL prefix
flowId string Yes The unique identifier of the workflow application
nodeId string Yes The unique identifier of the node to execute
params object Yes Input parameters for the node execution (typically key-value pairs matching the node's expected input variables)

Outputs (singleNodeRun)

Field Type Description
(return) Promise<any> The node execution result, including outputs, execution metadata, and status information

Inputs (getIterationSingleNodeRunUrl / getLoopSingleNodeRunUrl)

Parameter Type Required Description
flowType FlowType Yes The type of flow
isChatFlow boolean Yes Whether the workflow is an advanced-chat flow (affects URL path segment)
flowId string Yes The unique identifier of the workflow application
nodeId string Yes The unique identifier of the node to execute

Outputs (URL generators)

Field Type Description
(return) string The fully constructed API URL for the node run endpoint

Usage Examples

import { singleNodeRun, getIterationSingleNodeRunUrl, getLoopSingleNodeRunUrl } from '@/service/workflow'

// Run a standard Code node with test inputs
const result = await singleNodeRun('app', 'app-abc123', 'code-node-1', {
  inputs: { data: '{"key": "value"}' },
})

// Construct URL for an iteration-nested node (advanced-chat flow)
const iterUrl = getIterationSingleNodeRunUrl('app', true, 'app-abc123', 'llm-node-2')
// Result: "apps/app-abc123/advanced-chat/workflows/draft/iteration/nodes/llm-node-2/run"

// Construct URL for a loop-nested node (standard workflow flow)
const loopUrl = getLoopSingleNodeRunUrl('app', false, 'app-abc123', 'code-node-3')
// Result: "apps/app-abc123/workflows/draft/loop/nodes/code-node-3/run"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment