Skip to content

Graph quickstart

Define state, connect nodes, and invoke a compiled graph.

Updated View as Markdown
var schema = StateSchema.builder(GraphState.adapter())
        .channel("answer", StateChannel.lastValue())
        .build();

var graph = new StateGraph<>(schema)
        .addNode("answer", (state, runtime) ->
                completedFuture(new StateUpdate(Map.of("answer", "done"))))
        .addEdge(StateGraph.START, "answer")
        .addEdge("answer", StateGraph.END)
        .compile();

RunResult<GraphState> result = graph.invoke("customer-42", GraphState.empty())
        .toCompletableFuture().join();

Use stable thread IDs when a run must later be resumed or inspected.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close