Skip to the page

Reference · SDKs

SDKs

Turn each query file into a typed call in your language with napalm generate, then deploy the queries your app uses.

In the schema
—

Query files#

Put one EdgeQL statement in each .edgeql file inside dbschema/queries/. The filename becomes the operation name, so getNote.edgeql becomes getNote. A leading # comment on line 1 appears in the OpenAPI summary, SDK docstrings, project CLI --help text and MCP/A2A tool descriptions.

First-party TypeScript and Dart clients

napalm-client and napalm_client pair generated query bindings with PKCE sessions, causal bookmarks, multiplexed live queries, offline stores and resumable uploads.

Compiler-emitted OpenAPI 3.0 across eight languages

napalm generate compiles every .edgeql file against your schema to emit openapi.json and idiomatic typed SDKs with zero hand-written schemas.

dbschema/queries/getNote.edgeql
# Fetch one note with its authorselect Note {  title,  body,  created,  author: { name },}filter .id = <uuid>$id

Declare parameters with explicit casts (such as <uuid>$id or <optional str>$search). The compiler infers both the request parameter schema and the nested JSON return type directly from your project’s schema.

OpenAPI and SDK generation#

Terminal
napalm generate notes --lang ts

napalm generate compiles every query file against your project’s schema without executing anything. If a query references a missing field or fails typechecking, generation stops immediately with the compiler diagnostic. Make sure your project’s HTTP endpoint is enabled first (napalm endpoint notes --enable).

napalm/openapi.json
OpenAPI 3.0.3 spec defining a POST /query/{name} operation per file with full JSON Schema types for variables and data.
napalm/queries.*
Named constants holding each query string in your target language.
napalm/live.ts
Typed live-query subscription helpers for every read-only query (--lang ts and --lang dart).
napalm/hooks.ts
Typed React hooks (useGetNote, etc.) emitted automatically when React is in package.json.
Generated SDK
Idiomatic client bindings produced by your language’s standard OpenAPI generator.

Omit --lang when you only want napalm/openapi.json. Use -o <dir> to customize the output folder or --queries <dir> to read from another source directory.

Query deployment and passthrough#

During local development, generated clients include both query and variables in each request so you can edit .edgeql files without deploying first. For production, deploy your query directory to the server. Deploying also exposes your queries on your project CLI, MCP server and A2A agent.

Terminal
napalm queries push notesnapalm generate notes --deployed --lang ts
Calling a deployed query (--deployed)
const { data } = await db.POST('/query/getNote', {  body: { variables: { id } },})
All-or-nothing compile
napalm queries push compiles every file against your schema in one transaction. If any query fails to compile, nothing changes.
Protected migrations
napalm schema push recompiles all deployed queries inside the migration transaction and blocks any schema change that would break an existing deployed query.
Backward compatibility
Older clients that still send query in the body keep working. When {name} matches a deployed query, the server always runs the stored statement.
Migration blocked by a broken deployed query
napalm schema push notes
dbschema/queries/getNote.edgeql
InvalidReferenceError: object type 'default::Note' has no link or property 'body'
Nothing was applied because the new schema would break these queries. Fix the queries or the schema.

Locking down ad-hoc queries (passthrough)#

Once your application’s queries are deployed, lock down ad-hoc EdgeQL statements (POST /query), POST /ask and raw search/CDC calls with your endpoint’s passthrough setting.

--passthrough all
Default. Both user sessions and service keys can run ad-hoc statements alongside deployed queries.
--passthrough keys
Recommended for browser and mobile apps. Backend service keys can run ad-hoc queries, and end-user sessions can call only deployed queries (/query/{name} and /subscribe by name).
--passthrough none
Strictest lockdown. Sessions, service keys and agents can invoke only deployed queries. Ad-hoc statements return 403 deployed_query_required.

Project CLI, MCP and A2A exposure#

Every deployed query automatically becomes a typed subcommand on your project CLI, a tool on your MCP server and a skill on your A2A endpoint. Hide internal queries from the CLI or agents in the console or with napalm queries offer <project> <query> --no-cli / --no-agents.

Live OpenAPI spec (GET /openapi.json)#

Every project serves an OpenAPI 3.0 specification of its deployed queries at GET /openapi.json. Each operation carries the compiler-inferred extensions x-napalm-is-write, x-napalm-is-command and x-napalm-volatility (immutable, stable, volatile or modifying). Each operation also carries Napalm-Bookmark and Napalm-Freshness header schemas.

Query calls and bookmarks#

POST/query/getNote#

Request body (undeployed client)
{  "query": "# Fetch one note with its author\nselect Note { … }\nfilter .id = <uuid>$id",  "variables": { "id": "6f1c0e0e-5b7a-4c1e-9d2a-3f8b1e4c7a90" }}

If a deployed query has an action handler attached on the branch, calling /query/{name} runs the query under the caller’s access policies, forwards the matching rows to your HTTPS handler and returns the handler’s response. When the action declares an answerSchema, napalm generate types the generated method with that schema instead of the query’s row shape (and omits live-query helpers).

Automatic read-your-own-writes bookmarks#

Every query accepts an optional Napalm-Bookmark header and returns an updated bookmark so subsequent reads routed to replicas always observe prior writes. NapalmClient (napalm-client in TypeScript and napalm_client in Dart) tracks the highest bookmark automatically across HTTP calls and live subscriptions. Pass napalm.fetch or napalm.httpClient to your generated SDK. To merge a bookmark received out-of-band (such as a webhook’s position or another worker’s bookmark), call napalm.reach(bookmark). See Causal bookmarks.

EdgeQL to JSON type mapping#

Query inputs and results map directly to JSON and OpenAPI 3.0 schemas.

EdgeQL typeJSON / OpenAPI representation
strstring
int16, int32, int64integer
float32, float64number
bigint, decimalExact JSON number (full decimal precision preserved on the wire)
uuidstring (format: uuid)
datetime, cal::local_datestring (format: date-time or format: date)
Other cal::* types and durationISO 8601 string
bytesBase64 string (format: byte)
jsonArbitrary JSON value
enum<…>String union of the declared enum variant names
array<T> and multi fieldsTyped JSON array
tupleNamed tuples serialize as a typed object. Unnamed tuples serialize as an array
range<T>Object with lower, upper, inc_lower, inc_upper and empty
ext::pgvector::vectorarray of number
Optional single fieldT | null (null when the EdgeQL set is {})

Languages#

napalm generate --lang <lang> runs your language’s standard OpenAPI generator (or writes the build-plugin config for compiled toolchains). Each language has a page that covers setup, then signing people in, live queries, webhooks, the change log, uploads and search in that language.

TypeScript
openapi-typescript and openapi-fetch, with napalm-client for sessions, live queries, actions, webhooks, the change log, uploads and search.
Python
openapi-python-client, and the project’s HTTP API for the rest.
Go
oapi-codegen, and the project’s HTTP API for the rest.
Dart & Flutter
swagger_dart_code_generator, with napalm_client for sessions, live streams, webhooks, the change log, uploads and search.
Rust
progenitor, and the project’s HTTP API for the rest.
C#
Microsoft Kiota, and the project’s HTTP API for the rest.
Swift
Apple’s swift-openapi-generator, and the project’s HTTP API for the rest.
Kotlin
The OpenAPI Generator Gradle plugin, and the project’s HTTP API for the rest.

Type a word or two to search every docs page.