Skip to the page

Migrating · Platform guides

Coming from Gel

Your Gel schema and EdgeQL queries carry over directly. Napalm adds closed-by-default types, query-checked schema pushes and generated HTTP and SSE clients.

API
—
In the schema
ext::auth::Identity

What you’ll move#

This guide migrates a Gel application to Napalm. Your dbschema types and EdgeQL statements carry over directly after adding using extension napalm; to the schema. Three architectural pieces change: clients call deployed HTTPS queries instead of opening binary wire connections, types without access policies default to closed rather than open, and napalm schema push plans migrations declaratively without checked-in migration files.

On GelOn Napalm
createClient() over Gel’s binary protocolDeployed queries called by name over HTTPS from browsers, mobile apps or servers
Inline EdgeQL strings or query builder calls.edgeql files paired with generated SDK functions
Interactive client.transaction(…) blocksOne atomic EdgeQL statement per request
withGlobals(…) set by your backend serverGlobals bound directly from verified session tokens and service keys
Types without policies are open to all callersTypes without policies are closed over the Project API
gel migration create and gel migratenapalm schema push planned directly from .gel files
ext::auth configured via configure commandsnapalm sign-in commands and built-in auth routes
gel dump and gel restoreIdempotent batch import statements

Before you start#

Create a project in the console and sign in with the napalm CLI. Project endpoints speak HTTPS exclusively, so Gel’s binary client drivers, the gel CLI and psql do not connect directly. See Napalm and Gel for the complete compatibility reference.

Push your existing schema#

Add using extension napalm; to dbschema/default.gel and push your schema and query files to a rehearsal branch first.

Terminal
# Add using extension napalm; to your schema, then push to an isolated branchnapalm branches create notes rehearsalnapalm schema push notes --branch rehearsal # Compile your EdgeQL query files against the branchnapalm queries push notes --branch rehearsal

Five schema and migration details differ from a self-hosted or Gel Cloud instance:

Required extension
Declare using extension napalm; alongside your other using extension declarations. napalm schema push rejects schemas missing that declaration.
Declarative migrations
napalm schema push diffs your .gel files against the target branch and computes the migration plan directly, ignoring dbschema/migrations. Disambiguation prompts such as column renames or required-field backfills are recorded in dbschema/decisions.yaml.
Atomic query verification
Every schema push compiles all deployed queries against the updated schema inside the same transaction and aborts if any query would break.
No std::net calls
Napalm rejects schemas that import std::net. Replace database-originated HTTP calls with a notify webhook on the type, an action or a background job.
Supported extensions
Protocol listeners such as graphql and edgeql_http are disabled, while auth, ai and pgcrypto work unchanged.

Add access rules to every type#

Default-closed access is the first behavior shift to plan for. On Gel, any type without an access policy is readable and writable by every connection. On Napalm, that type denies all Project API requests until you add an access policy.

dbschema/default.gel
# Gel leaves this type open to all callers, while Napalm closes it by defaulttype Tag {  required name: str;} # Allow any signed-in caller to read Tag rowstype Tag {  required name: str;   access policy signed_in_can_read    allow select    using (exists global caller);}

Existing access policies carry over with one adjustment: Napalm binds caller identity directly from the verified session token into ext::auth::ClientTokenIdentity, rather than trusting a custom UUID global set by an application server.

dbschema/default.gel
# Before: a mutable connection global set by your backend serverglobal current_user_id: uuid; # After: the verified caller identity bound from the session tokenglobal caller := global ext::auth::ClientTokenIdentity;

Together, default-closed types and token-bound globals let browsers and mobile apps query your project directly without a middle-tier server:

Closed by default

Every stored object type denies API requests until an explicit access rule matches.

Token-bound globals

Napalm binds caller identity from verified tokens instead of server-supplied connection globals.

Use the CLI and branch settings to audit policy coverage and configure non-user globals:

Auditing closed types
napalm status notes lists every type closed to the Project API, and napalm keys reach notes --new counts how many rows a service key can read, update or delete per type.
Service and user globals
Role or tenant globals previously passed via withGlobals move into your branch’s serviceGlobals or userGlobals configuration, bound automatically on matching requests.
Scoped service keys
Service keys never bypass access policies. Backend services read and write strictly under policies matching their configured role.

Replace wire clients with deployed queries#

In a Gel app, a backend route typically holds a binary client connection, sets current_user_id with withGlobals and executes inline EdgeQL strings.

Before: server holding a binary connection
// src/notes.tsimport { createClient } from 'gel' // A connection to the instance, held by a server of yours. The server says who is asking.const client = createClient() export const listNotes = (me: string) =>  client.withGlobals({ current_user_id: me }).query<{ id: string; title: string }>(`select Note { id, title }`) export const addNote = (me: string, title: string) =>  client.transaction(async (tx) => {    const author = await tx.queryRequiredSingle<{ id: string }>(`select Person { id } filter .id = <uuid>$me`, { me })    return tx.queryRequiredSingle<{ id: string }>(      `insert Note { title := <str>$title, author := (select Person filter .id = <uuid>$author) }`,      { title, author: author.id },    )  })

Move each EdgeQL query from inline application strings into a dedicated file under dbschema/queries and replace server-supplied user globals with global caller. Multi-step read-then-write transactions fold into single nested EdgeQL statements.

dbschema/queries/myNotes.edgeql
# The notes the caller owns or was given. The rules decide which: the query doesn't say.select Note { id, title, body, created, is_mine := .owner.identity ?= global caller }order by .created desc
dbschema/queries/addNote.edgeql
# A note of the caller's own. Someone with no person yet has no owner to give it, and it's refused.insert Note {  owner := assert_exists(assert_single((select Person filter .identity ?= global caller))),  title := <str>$title,  body := <str>$body,}
Direct browser calls
Remove backend endpoints that existed only to hold a Gel connection pool. Browser and mobile clients call deployed queries directly with the user’s session token while schema rules enforce row access. Your first app walks through that setup.
Generated SDKs
napalm generate emits typed functions for each .edgeql file in place of the TypeScript query builder and @gel/generate. SDKs covers all eight target languages.
Single-statement transactions
Each HTTP request executes one atomic EdgeQL statement. Combine dependent reads and writes inside one statement using with bindings.
Backend callers
Server processes call the same deployed HTTPS queries either by forwarding a user session or by authenticating with a branch-scoped service key. A backend service covers server integration.

Import existing rows#

Because binary gel dump archives cannot be restored onto a project, you migrate data through idempotent EdgeQL import statements over HTTPS.

Batch statement imports

Export scripts stream Gel objects over HTTPS and relink records by legacy ID.

The export script (scripts/from-gel.ts) reads objects from your existing Gel instance and sends batches through the helper in Switching over.

scripts/from-gel.ts
// scripts/from-gel.tsimport { createClient } from 'gel'import { move } from './send' // The old instance, found the way the Gel client always finds one: GEL_DSN, or the project's own instance. Its// access policies are off for this read: they'd hide every row from a script nobody is signed in to.const old = createClient().withConfig({ apply_access_policies: false }) /** A type's objects in the order of their ids, a thousand at a time. */async function* pages<Row extends { id: string }>(query: string) {  let after = '00000000-0000-0000-0000-000000000000'  for (;;) {    const rows = await old.query<Row>(query, { after })    if (rows.length === 0) return    yield* rows    after = rows[rows.length - 1].id  }} /** Each note as the import statement reads a row: a shape can't give a link's name to a list of ids. */async function* notes() {  const found = pages<{ id: string; owner_id: string; shares: string[]; title: string; body: string }>(`    select Note { id, owner_id := .author.id, shares := array_agg(.shared_with.id), title, body := .body ?? '' }    filter .id > <uuid>$after    order by .id    limit 1000`)  for await (const { shares, ...note } of found) yield { ...note, shared_with: shares }} // People first: a note names its owner. Each comes with the address or the provider account its identity had.await move(  'importPeople',  pages(`    select Person {      id,      name,      email := (select ext::auth::EmailFactor filter .identity = Person.identity limit 1).email,      sign_ins := [.identity.issuer ++ ' ' ++ .identity.subject] if .identity.issuer != 'local' else <array<str>>[],    }    filter .id > <uuid>$after    order by .id    limit 1000`),)await move('importNotes', notes())await old.close()
Terminal
npm install gel tsxGEL_DSN=gel://… NAPALM_URL=https://<project-address>/branches/rehearsal NAPALM_KEY=ndb_… \  npx tsx scripts/from-gel.ts
Disable old policies on export
Connect to the source Gel instance with apply_access_policies: false (as shown in scripts/from-gel.ts) so the export client can read all rows without impersonating individual users.
Remapped UUIDs
Every imported object receives a fresh id on Napalm while storing its original Gel UUID in old_id. Import statements upsert on old_id and resolve links through it.
Auth identities
ext::auth records and password hashes remain on the source Gel instance. Import each user as a Person with an optional identity link so returning users reclaim their rows at first sign-in, following Moving your users.

Migrate auth, webhooks and tooling#

Sign-in providers
Configure OAuth, OIDC and magic-link providers with napalm sign-in instead of EdgeQL configure commands. Client SDKs handle PKCE sign-in and session refresh automatically. Sign-in for your app covers every provider.
AI and semantic search
Declarative ext::ai indexes work unchanged. Because callers cannot invoke ext::ai::search directly in ad-hoc queries, wrap semantic search inside a schema function or call POST /search.
Webhooks and jobs
Replace std::net triggers with a notify webhook declaration on the type or a transactional job.
CLI queries and console
napalm query executes statements under a service key governed by your access rules, and the web console inspects schemas, query performance and caller reach.

Check the migration#

  1. Push schema and queries to the branch

    napalm schema push notes --branch rehearsal applies your schema, and napalm queries push notes --branch rehearsal compiles every .edgeql query file.

  2. Query a type without an access rule

    A type with no policy returns zero rows to user sessions and service keys alike until you add an access policy and push.

  3. Run the export script twice

    Both runs print identical counts matching your source Gel instance.

  4. Sign in as an imported user

    Owned notes appear immediately, and queries that previously accepted a manual $user_id parameter now rely solely on global caller.

Type a word or two to search every docs page.