Logic

Run your backend code on Napalm.

Gatekeeper queries check caller access before your handler runs. Hosted functions run in five languages, and jobs commit in the same transaction as your writes.

Read the actions docs

Actions

Actions check access before code runs.

A gatekeeper query runs first under the caller’s access rules. When zero rows match, Napalm returns 403 nothing_found before your handler wakes. Inside the handler, call.db() opens a 60-second session bound to the caller.

Actions
handlers/refundOrder.ts
import type { Handler } from 'napalm-client' type Order = { id: string; total_cents: number; stripe_charge_id: string } const refundOrder: Handler<Order> = async (call) => {  const [order] = call.rows  const refund = await stripe.refunds.create(    { charge: order.stripe_charge_id, amount: order.total_cents },    { idempotencyKey: call.job?.id ?? `refund:${order.id}` },  )  const db = await call.db() // 60-second session as the caller  await db.fetch(`${call.address}/query/markOrderRefunded`, {    method: 'POST',    headers: { 'Content-Type': 'application/json' },    body: JSON.stringify({ variables: { order: order.id } }),  })  return { refundId: refund.id, status: 'refunded' }} export default refundOrder

Hosted functions

Run hosted functions in five languages.

Deploy handlers in TypeScript, Python, Go, Rust or Dart, or ship a container by digest. Idle handler machines sleep between calls and wake in a few hundred milliseconds.

Terminal
napalm queries push shopnapalm handlers secrets set shop STRIPE_SECRET_KEYnapalm handlers deploy shop
Hosted handlers

Cron schedules

Run cron schedules in any time zone.

Put any deployed query or action on a five-field cron in an IANA time zone. Scheduled runs authenticate as a chosen service key and obey your schema’s access rules.

Terminal
napalm schedules add shop rollUpUsage '0 3 * * *' \  --time-zone America/Los_Angeles \  --key $SERVICE_KEY_ID
Jobs and schedules

Transactional jobs

Jobs commit inside your write transaction.

Insert an ext::napalm::Job record in the same statement as your mutation. Both changes commit or roll back together, so you need no message broker or outbox poller. Failed attempts retry after 10 seconds at doubling delays up to 1 hour.

Jobs and schedules
dbschema/queries/placeOrder.edgeql
# Place an order and atomically enqueue receipt deliverywith  order := (    insert Order {      buyer := assert_exists(global caller),      total_cents := <int64>$total_cents,      status := OrderStatus.Paid,      stripe_charge_id := <str>$charge_id,    }  ),  receipt_job := (    insert ext::napalm::Job {      query := 'sendReceipt',      variables := <json>(order := <str>order.id),    }  ),  followup_job := (    insert ext::napalm::Job {      query := 'checkDelivery',      variables := <json>(order := <str>order.id),      run_time := datetime_of_statement() + <duration>'72 hours',    }  ),select {  order_id := order.id,  receipt_job_id := receipt_job.id,}

Signed webhooks

Send signed webhooks after each commit.

Declare notify on any type. After a matching transaction commits, Napalm sends an HMAC-signed ping or access-filtered row batch and retries failed deliveries.

dbschema/default.gel
type Order {  required buyer: ext::auth::Identity;  required status: OrderStatus;   access policy buyer_can_read    allow select using (.buyer ?= global caller);   notify order_changed after insert, update, delete;}
Notifications and webhooks

Job status

Query job status like any other row.

Every queued job is a typed record in your graph. Callers read status and attempt history under the same access rules, and live subscriptions stream progress to the UI without polling.

dbschema/queries/jobStatus.edgeql
# Watch a queued job and its attempt historyselect ext::napalm::Job {  id,  query,  status,  run_time,  finish_time,  runs: {    status,    start_time,    finish_time,    error,  } order by .start_time desc,}filter .id = <uuid>$job
Jobs and schedules