[PR #1029] [MERGED] feat(pregel): add zod plugin #1182

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

📋 Pull Request Information

Original PR: https://github.com/langchain-ai/langgraphjs/pull/1029
Author: @dqbd
Created: 3/25/2025
Status: Merged
Merged: 3/25/2025
Merged by: @dqbd

Base: mainHead: dqbd/zod-plugin


📝 Commits (8)

  • c166389 feat(pregel): add zod plugin
  • 83bba39 use plugin entrypoint
  • a6a51ac Add entrypoint
  • 5d343ce Add quick mention
  • f6c2fa6 Use WeakSet to allow patching from multiple Zod instances, rely on .default() instead, remove buggy input, outputconstructor arg
  • 994551a Export withLangGraph
  • 0ac5066 Add error to lib
  • d9b307d Last try

📊 Changes

13 files changed (+293 additions, -121 deletions)

View changed files

📝 examples/how-tos/define-state.ipynb (+33 -0)
📝 examples/tsconfig.json (+1 -0)
📝 libs/langgraph/.gitignore (+4 -0)
📝 libs/langgraph/langchain.config.js (+2 -1)
📝 libs/langgraph/package.json (+14 -1)
📝 libs/langgraph/src/graph/state.ts (+1 -41)
libs/langgraph/src/graph/zod/index.ts (+3 -0)
libs/langgraph/src/graph/zod/plugin.ts (+79 -0)
📝 libs/langgraph/src/graph/zod/schema.ts (+77 -56)
📝 libs/langgraph/src/graph/zod/state.ts (+23 -2)
📝 libs/langgraph/src/tests/pregel.test.ts (+54 -18)
📝 libs/langgraph/tsconfig.json (+1 -1)
📝 tsconfig.json (+1 -1)

📄 Description

Uses the proposed mechanism for Zod plugins: https://github.com/colinhacks/zod/pull/3445

Example usage:

const schema = z.object({
  list: z.array(z.string).default(() => ["default"])
    .langgraph.reducer(
      (a, b) => [...a, ...(Array.isArray(b) ? b : [b])],
      z.union([z.array(z.string()), z.string()])
    )
    .langgraph.metadata({ ... })
})


🔄 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/1029 **Author:** [@dqbd](https://github.com/dqbd) **Created:** 3/25/2025 **Status:** ✅ Merged **Merged:** 3/25/2025 **Merged by:** [@dqbd](https://github.com/dqbd) **Base:** `main` ← **Head:** `dqbd/zod-plugin` --- ### 📝 Commits (8) - [`c166389`](https://github.com/langchain-ai/langgraphjs/commit/c1663896c2602ebe34cfa294f8f8696c6385cb2a) feat(pregel): add zod plugin - [`83bba39`](https://github.com/langchain-ai/langgraphjs/commit/83bba397010e60f02e6aa64e7aa64bc1ebcc7048) use plugin entrypoint - [`a6a51ac`](https://github.com/langchain-ai/langgraphjs/commit/a6a51aca408bc1df529e7e9c221ea30d1967cea7) Add entrypoint - [`5d343ce`](https://github.com/langchain-ai/langgraphjs/commit/5d343cefe76693df80355fc922c7e4c3739e8d5e) Add quick mention - [`f6c2fa6`](https://github.com/langchain-ai/langgraphjs/commit/f6c2fa6a6ead0d68cf4ad87239e9b59a30595d9a) Use WeakSet to allow patching from multiple Zod instances, rely on .default() instead, remove buggy `input, output`constructor arg - [`994551a`](https://github.com/langchain-ai/langgraphjs/commit/994551ab5a8b7548a50b4837569c69f832f6d412) Export withLangGraph - [`0ac5066`](https://github.com/langchain-ai/langgraphjs/commit/0ac5066b7c83dce09625387d3d4b422bd2ad3c77) Add error to lib - [`d9b307d`](https://github.com/langchain-ai/langgraphjs/commit/d9b307d28362b3a909c45aaa438d1941245f84e3) Last try ### 📊 Changes **13 files changed** (+293 additions, -121 deletions) <details> <summary>View changed files</summary> 📝 `examples/how-tos/define-state.ipynb` (+33 -0) 📝 `examples/tsconfig.json` (+1 -0) 📝 `libs/langgraph/.gitignore` (+4 -0) 📝 `libs/langgraph/langchain.config.js` (+2 -1) 📝 `libs/langgraph/package.json` (+14 -1) 📝 `libs/langgraph/src/graph/state.ts` (+1 -41) ➕ `libs/langgraph/src/graph/zod/index.ts` (+3 -0) ➕ `libs/langgraph/src/graph/zod/plugin.ts` (+79 -0) 📝 `libs/langgraph/src/graph/zod/schema.ts` (+77 -56) 📝 `libs/langgraph/src/graph/zod/state.ts` (+23 -2) 📝 `libs/langgraph/src/tests/pregel.test.ts` (+54 -18) 📝 `libs/langgraph/tsconfig.json` (+1 -1) 📝 `tsconfig.json` (+1 -1) </details> ### 📄 Description Uses the proposed mechanism for Zod plugins: https://github.com/colinhacks/zod/pull/3445 Example usage: ``` const schema = z.object({ list: z.array(z.string).default(() => ["default"]) .langgraph.reducer( (a, b) => [...a, ...(Array.isArray(b) ? b : [b])], z.union([z.array(z.string()), z.string()]) ) .langgraph.metadata({ ... }) }) ``` --- <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:17:34 -05:00
yindo closed this issue 2026-02-15 19:17:34 -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#1182