[PR #701] [MERGED] fix(langgraph): Add test for invoking a single node #945

Closed
opened 2026-02-15 19:16:30 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/701
Author: @bracesproul
Created: 12/4/2024
Status: Merged
Merged: 12/4/2024
Merged by: @bracesproul

Base: mainHead: brace/invoke-single-node


📝 Commits (3)

📊 Changes

1 file changed (+30 additions, -0 deletions)

View changed files

📝 libs/langgraph/src/tests/pregel.test.ts (+30 -0)

📄 Description

Turns out it's already possible!

const graph = new StateGraph(MessagesAnnotation)
  .addNode("one", (state) => {
    if (!state.messages.length) {
      throw new Error("State not found");
    }
    return {
      messages: [
        ...state.messages,
        {
          role: "user",
          content: "success",
        },
      ],
    };
  })
  .addNode("two", () => {
    throw new Error("Should not be called");
  })
  .addEdge(START, "one")
  .addEdge("one", "two")
  .addEdge("two", END)
  .compile();
const result = await graph.nodes.one.invoke({
  messages: [new HumanMessage("start")],
});
expect(result.messages).toBeDefined();
expect(result.messages).toHaveLength(2);

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/langchain-ai/langgraphjs/pull/701 **Author:** [@bracesproul](https://github.com/bracesproul) **Created:** 12/4/2024 **Status:** ✅ Merged **Merged:** 12/4/2024 **Merged by:** [@bracesproul](https://github.com/bracesproul) **Base:** `main` ← **Head:** `brace/invoke-single-node` --- ### 📝 Commits (3) - [`e3e8f76`](https://github.com/langchain-ai/langgraphjs/commit/e3e8f7628d293f263101aa1796694b88896526dd) fix(langgraph): Add test for invoking a single node - [`4347cf8`](https://github.com/langchain-ai/langgraphjs/commit/4347cf8b52d3b5d4c5bcd8043307ab9a66739cf9) chore: lint files - [`bb6c375`](https://github.com/langchain-ai/langgraphjs/commit/bb6c375d5ebb9d0485bfeb10bc1503a98bba608c) unfocus ### 📊 Changes **1 file changed** (+30 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `libs/langgraph/src/tests/pregel.test.ts` (+30 -0) </details> ### 📄 Description Turns out it's already possible! ```typescript const graph = new StateGraph(MessagesAnnotation) .addNode("one", (state) => { if (!state.messages.length) { throw new Error("State not found"); } return { messages: [ ...state.messages, { role: "user", content: "success", }, ], }; }) .addNode("two", () => { throw new Error("Should not be called"); }) .addEdge(START, "one") .addEdge("one", "two") .addEdge("two", END) .compile(); const result = await graph.nodes.one.invoke({ messages: [new HumanMessage("start")], }); expect(result.messages).toBeDefined(); expect(result.messages).toHaveLength(2); ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-15 19:16:30 -05:00
yindo closed this issue 2026-02-15 19:16:30 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#945