effect-rpc-pipeline
Effect-native RPC promise pipelining.
Connect typed RPC calls into a single graph. The server resolves dependencies, runs independent work concurrently, and returns the data you select.
npm install effect-rpc-pipeline effectconst user = rpc.findUser({ email })
const account = yield* Pipeline.all({
user,
profile: rpc.getProfile({ userId: user.id }),
friendIds: rpc.listFriendIds({ userId: user.id })
})Built for Effect
Compose RPC calls with the schemas, typed errors, services, and resource scopes you already use.
See how it works ↓02Fewer round trips
Send dependent calls together so the next lookup can start on the server without another trip to the client.
See how it works ↓03Selected results
Choose the fields returned by a query or the refreshed data returned after a mutation.
See how it works ↓01 / EFFECT INTEGRATION
Use the Effect APIs you already know.
Define your RPCs with Effect Schema and implement them with ordinary Effect handlers. The same RPC group gives the client its payload, result, and error types.
A remote call is an Effect. Yield it in Effect.gen, handle a declared failure with catchTag, and provide application services through Layers.
See authentication with Effect services →const loadUser = Effect.gen(function*() {
const rpc = yield* AppClient
return yield* rpc.findUser({ email }).pipe(
Effect.catchTag(
"UserNotFound",
() => Effect.succeed(null)
)
)
}).pipe(Effect.provide(AppClientLive))AppClient is an Effect service; AppClientLive supplies its HTTP implementation. This example uses the declared UserNotFound error.
HTTP executions own an internal request scope. WebSocket Layers own the connection used by streams and capability handles.
02 / FEWER ROUND TRIPS
Start the next lookup on the server.
Suppose a page needs a user and that user’s profile. Sequential client calls wait for the user to arrive before requesting the profile.
A pipeline sends both operations together. The server passes the user ID straight into getProfile, saving one network round trip in this example. That removes a wait from the page load.
Independent calls can also run concurrently, up to the server’s limit. Handler and database work still take their usual time.
Read how pipeline execution works →const user = rpc.findUser({ email })
const profile = yield* rpc.getProfile({
userId: user.id
})user.id is a reference to the future result. Only the final yield sends the complete graph.
Sequential RPC calls
2 round trips- Client
findUserClient - Client
getProfileClient
The client waits for the user ID between requests.
Pipelined RPC calls
1 round trip- Client
findUser → getProfileClient
The server resolves the dependency within one request.
03 / SELECTED RESULTS
Return the fields your screen needs.
Select fields from several RPCs into the response shape you want. The server can use intermediate values, such as a user ID, without returning them to the client.
After a mutation, use andThen to choose the refreshed data that comes back. The follow-up reads wait for the write and stay in the same pipeline request.
const user = rpc.findUser({ email })
const account = yield* Pipeline.all({
name: user.name,
bio: rpc.getProfile({ userId: user.id }).bio
})Find the user, then select their name and profile bio.
↓ Selected response
{
"name": "Ada",
"bio": "Builds with Effect"
}Selection controls the response payload. Backend queries and transaction boundaries remain explicit choices in your handlers and server configuration.
Explore selections, maps, and mutation phases →GO FURTHER
A pipeline is just the beginning.
Capabilities & callbacks↗
Return typed, connection-scoped interfaces and call back into the client.
Backend batching↗
Combine one pipeline request with request-scoped caches and bulk reads.
SQL transactions↗
Wrap graph execution in a transaction and defer effects until commit.
Complete API reference↗
Explore every exported module, type, and function signature.
START SMALL
Your first pipeline, end to end.
Define a contract. Start a server. Compose a client.