Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 1.01 KB

branch.md

File metadata and controls

52 lines (29 loc) · 1.01 KB

quetch


quetch / branch

Function: branch()

branch<I, O, In, On>(condition, left, right): Handler<I, O, In, On>

Dispatches an incoming query to left if condition(query) returns a truthy value, right otherwise. This is helpful for sending queries to different resolvers.

Type Parameters

I

O

In

On

Parameters

condition

(input) => boolean

left

Handler<I, O, In, On>

right

Handler<I, O, In, On> = ...

Returns

Handler<I, O, In, On>

Example

const customFetch = combine(
  branch(query => query.protocol === 'gql', gqlHandlers),
  restHandlers,
)

Defined in

lib/middlewares/branch.ts:21