Skip to content

waygraph / ApiBlockOptions

Interface: ApiBlockOptions<In, Out> ​

Defined in: src/engine/block/kinds/api.ts:29

Options for defineApiBlock: the HTTP call, how its result maps to a Checkpoint, and the demo network panel.

Type Parameters ​

In ​

In extends Checkpoint<string>

Out ​

Out extends Checkpoint<string>

Properties ​

call ​

call: (ctx) => Promise<APIResponse<any>>

Defined in: src/engine/block/kinds/api.ts:37

Make the request - request is Playwright's own page.request (same cookies/origin as the browser context, so an authenticated UI session carries over to the API call for free).

Parameters ​

ctx ​
mem ​

MemPage

request ​

APIRequestContext

Returns ​

Promise<APIResponse<any>>

Example ​

ts
call: ({ request }) => request.get("/api/orders/1")

description? ​

optional description?: string

Defined in: src/engine/block/kinds/api.ts:31


expect? ​

optional expect?: ExpectList<Out>

Defined in: src/engine/block/kinds/api.ts:59

What this Block promises wherever it's used, checked after its verify: Expect Blocks, Traits, Key.is(...). A Block that can land in several places lists them per outcome. Read-only and run together; a step can drop them ({ expect: false }) or add its own.

Example ​

ts
expect: [ExpectArchivedToastBlock] · expect: { EquipmentDetail: [ExpectSavedBlock], EquipmentAdd: [ExpectNameRequiredBlock] }

from? ​

optional from?: In | readonly In[]

Defined in: src/engine/block/kinds/api.ts:47

Where it runs: one Checkpoint value or a list; leave it out for "from anywhere".


method? ​

optional method?: string

Defined in: src/engine/block/kinds/api.ts:45

HTTP method shown in the network-tab overlay (GET/POST/PATCH/...) - APIResponse (unlike a page's own Response) carries no back-reference to the request that produced it, so this can't be read back automatically; defaults to "GET" if omitted. Purely cosmetic - never affects the actual request call makes.

Example ​

ts
method: "POST"

name ​

name: string

Defined in: src/engine/block/kinds/api.ts:30


requires? ​

optional requires?: readonly MemKey<unknown>[]

Defined in: src/engine/block/kinds/api.ts:60


resolve? ​

optional resolve?: (result) => Out

Defined in: src/engine/block/kinds/api.ts:51

Pure, like every other Block's resolve - picks the Checkpoint from the response. Optional when to is one Checkpoint.

Parameters ​

result ​

ApiCallResult

Returns ​

Out


to ​

to: Out | readonly Out[]

Defined in: src/engine/block/kinds/api.ts:49

Where it lands: one Checkpoint value (then resolve may be left out) or a list.


undo? ​

optional undo?: (ctx) => Promise<APIResponse<any>>

Defined in: src/engine/block/kinds/api.ts:67

What puts the world back after this Block made something (delete what call created). When the Block is a flow's given (a precondition), it runs after the flow, pass or fail, in the reverse order of the givens; its failure is reported and never decides the flow. Read mem for the id call stored.

Parameters ​

ctx ​
mem ​

MemPage

request ​

APIRequestContext

Returns ​

Promise<APIResponse<any>>

Example ​

ts
undo: ({ request, mem }) => request.delete(`/posts/${mem.get(SeededId)}`)

verify? ​

optional verify?: Trait[] | ((out) => Trait[])

Defined in: src/engine/block/kinds/api.ts:52

waygraph 0.18.3 (alpha) · Node 24+ · peer @playwright/test ^1.40.0 · syntax may change before 1.0: see what was removed